Merge "feat: Add time_expired into cookie"

This commit is contained in:
Zuul 2023-06-07 11:29:23 +00:00 committed by Gerrit Code Review
commit ca3b13fd9a
4 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
features:
- |
Add ``time_expired`` into cookie, so that skyline-console can follow this
value to check whether the token is valid or not.

View File

@ -80,4 +80,5 @@ async def get_profile_update_jwt(request: Request, response: Response) -> schema
if 0 < profile.exp - time.time() < CONF.default.access_token_renew:
profile.exp = int(time.time()) + CONF.default.access_token_expire
response.set_cookie(CONF.default.session_name, profile.toJWTPayload())
response.set_cookie(constants.TIME_EXPIRED_KEY, str(profile.exp))
return profile

View File

@ -184,6 +184,7 @@ async def login(
)
else:
response.set_cookie(CONF.default.session_name, profile.toJWTPayload())
response.set_cookie(constants.TIME_EXPIRED_KEY, str(profile.exp))
return profile
@ -279,6 +280,7 @@ async def websso(
else:
response = RedirectResponse(url="/base/overview", status_code=status.HTTP_302_FOUND)
response.set_cookie(CONF.default.session_name, profile.toJWTPayload())
response.set_cookie(constants.TIME_EXPIRED_KEY, str(profile.exp))
return response
@ -378,4 +380,5 @@ async def switch_project(
)
else:
response.set_cookie(CONF.default.session_name, profile.toJWTPayload())
response.set_cookie(constants.TIME_EXPIRED_KEY, str(profile.exp))
return profile

View File

@ -66,3 +66,6 @@ SUPPORTED_SERVICE_EPS = {
"trove": ["trove"],
"zun": ["zun"],
}
# Key of Time Expired in Cookie
TIME_EXPIRED_KEY = "time_expired"