From 6f2973c1b1295ce88f82e483017e2e8563429d8c Mon Sep 17 00:00:00 2001 From: knst-kotov Date: Thu, 2 Jun 2022 10:39:44 +0300 Subject: [PATCH] set cookie on oauth --- auth/oauth.py | 6 ++++-- settings.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/auth/oauth.py b/auth/oauth.py index 90903583..ee474774 100644 --- a/auth/oauth.py +++ b/auth/oauth.py @@ -83,5 +83,7 @@ async def oauth_authorize(request): } user = Identity.identity_oauth(user_input) token = await Authorize.authorize(user, device="pc") - redirect_uri = "%s%s" % (OAUTH_CALLBACK_URL, quote_plus(token)) - return RedirectResponse(url = redirect_uri) + + response = RedirectResponse(url = OAUTH_CALLBACK_URL) + response.set_cookie("token", token) + return response diff --git a/settings.py b/settings.py index 4a10faf4..3998a99f 100644 --- a/settings.py +++ b/settings.py @@ -5,7 +5,7 @@ PORT = 8080 INBOX_SERVICE_PORT = 8081 BACKEND_URL = environ.get("BACKEND_URL") or "https://localhost:8080" -OAUTH_CALLBACK_URL = environ.get("OAUTH_CALLBACK_URL") or "https://localhost:8080/auth/key-" +OAUTH_CALLBACK_URL = environ.get("OAUTH_CALLBACK_URL") or "https://localhost:8080" RESET_PWD_URL = environ.get("RESET_PWD_URL") or "https://localhost:8080/reset_pwd" DB_URL = environ.get("DATABASE_URL") or environ.get("DB_URL") or "sqlite:///db.sqlite3"