diff --git a/backend/src/auth/users.py b/backend/src/auth/users.py index 2a2fe90..f4c929c 100644 --- a/backend/src/auth/users.py +++ b/backend/src/auth/users.py @@ -101,7 +101,8 @@ class RedirectingCookieTransport(CookieTransport): bearer_transport = BearerTransport(tokenUrl="auth/jwt/login") -cookie_transport = RedirectingCookieTransport(cookie_max_age=LIFETIME) +cookie_transport = CookieTransport(cookie_max_age=LIFETIME) +oauth_cookie_transport = RedirectingCookieTransport(cookie_max_age=LIFETIME) bearer_auth_backend = AuthenticationBackend( name="jwt", @@ -113,6 +114,11 @@ cookie_auth_backend = AuthenticationBackend( transport=cookie_transport, get_strategy=get_jwt_strategy, ) +oauth_cookie_auth_backend = AuthenticationBackend( + name="cookie", + transport=oauth_cookie_transport, + get_strategy=get_jwt_strategy, +) fastapi_users = FastAPIUsers[User, uuid.UUID](get_user_manager, [bearer_auth_backend, cookie_auth_backend]) diff --git a/backend/src/main.py b/backend/src/main.py index f2c5970..dbac72d 100644 --- a/backend/src/main.py +++ b/backend/src/main.py @@ -62,7 +62,7 @@ from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from fastapi.staticfiles import StaticFiles from auth.schemas import UserCreate, UserRead, UserUpdate -from auth.users import bearer_auth_backend, fastapi_users, cookie_auth_backend +from auth.users import bearer_auth_backend, fastapi_users, cookie_auth_backend, oauth_cookie_auth_backend from auth.router import users_router as custom_users_router from auth.router import auth_metadata_router basic_config = BasicConfig() @@ -136,7 +136,7 @@ app.include_router( if oauth_client is not None: app.include_router( fastapi_users.get_oauth_router(oauth_client, - cookie_auth_backend, + oauth_cookie_auth_backend, auth.users.SECRET, associate_by_email=True, is_verified_by_default=True,