aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2021-02-19 10:13:17 +0300
committerGravatar Hassan Abouelela <[email protected]>2021-02-20 03:30:29 +0300
commitf6b09f5366a0921d12707c444a8bd86e05b7df19 (patch)
tree6a623795140ba5629d51ea18b23d1d102c31915b
parentAdds CORS Rules (diff)
Adds Expiry To Authorization Routes
Signed-off-by: Hassan Abouelela <[email protected]>
-rw-r--r--backend/routes/auth/authorize.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/backend/routes/auth/authorize.py b/backend/routes/auth/authorize.py
index 2244152..c6cd86c 100644
--- a/backend/routes/auth/authorize.py
+++ b/backend/routes/auth/authorize.py
@@ -28,6 +28,7 @@ class AuthorizeRequest(BaseModel):
class AuthorizeResponse(BaseModel):
username: str = Field("Discord display name.")
+ expiry: str = Field("ISO formatted timestamp of expiry.")
AUTH_FAILURE = JSONResponse({"error": "auth_failure"}, status_code=400)
@@ -56,7 +57,11 @@ async def process_token(bearer_token: dict) -> Union[AuthorizeResponse, AUTH_FAI
token = jwt.encode(data, SECRET_KEY, algorithm="HS256")
user = User(token, user_details)
- response = JSONResponse({"username": user.display_name})
+ response = JSONResponse({
+ "username": user.display_name,
+ "expiry": token_expiry.isoformat()
+ })
+
response.set_cookie(
"BackendToken", f"JWT {token}",
secure=constants.PRODUCTION, httponly=True, samesite="strict",