Revamp OAuth documentation

This commit is contained in:
François Voron
2022-05-05 10:54:29 +02:00
parent 617246a438
commit 43c73cdbcb
35 changed files with 202 additions and 549 deletions

View File

@ -1,7 +1,7 @@
from fastapi import Depends, FastAPI
from app.db import create_db_and_tables
from app.models import UserDB
from app.db import User, create_db_and_tables
from app.schemas import UserCreate, UserRead, UserUpdate
from app.users import (
auth_backend,
current_active_user,
@ -14,18 +14,26 @@ app = FastAPI()
app.include_router(
fastapi_users.get_auth_router(auth_backend), prefix="/auth/jwt", tags=["auth"]
)
app.include_router(fastapi_users.get_register_router(), prefix="/auth", tags=["auth"])
app.include_router(
fastapi_users.get_register_router(UserRead, UserCreate),
prefix="/auth",
tags=["auth"],
)
app.include_router(
fastapi_users.get_reset_password_router(),
prefix="/auth",
tags=["auth"],
)
app.include_router(
fastapi_users.get_verify_router(),
fastapi_users.get_verify_router(UserRead),
prefix="/auth",
tags=["auth"],
)
app.include_router(fastapi_users.get_users_router(), prefix="/users", tags=["users"])
app.include_router(
fastapi_users.get_users_router(UserRead, UserUpdate),
prefix="/users",
tags=["users"],
)
app.include_router(
fastapi_users.get_oauth_router(google_oauth_client, auth_backend, "SECRET"),
prefix="/auth/google",
@ -34,7 +42,7 @@ app.include_router(
@app.get("/authenticated-route")
async def authenticated_route(user: UserDB = Depends(current_active_user)):
async def authenticated_route(user: User = Depends(current_active_user)):
return {"message": f"Hello {user.email}!"}