feat: Add time_expired into cookie
Now the expired time for skyline and keystone is not the same value. Sometime, when the token of keystone is valid but the jwt token of skyline-apiserver is invalid. The skyline-console will send the request to backend service and then get 401 from skyline. So we add time_expired into cookie, then skyline-console can check whether time expired or not. Change-Id: Id1d3a83eb433c18e88828115e8bd744151fb14f7
This commit is contained in:
parent
de22d3ba3b
commit
9c4f5e5e74
@ -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.
|
@ -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:
|
if 0 < profile.exp - time.time() < CONF.default.access_token_renew:
|
||||||
profile.exp = int(time.time()) + CONF.default.access_token_expire
|
profile.exp = int(time.time()) + CONF.default.access_token_expire
|
||||||
response.set_cookie(CONF.default.session_name, profile.toJWTPayload())
|
response.set_cookie(CONF.default.session_name, profile.toJWTPayload())
|
||||||
|
response.set_cookie(constants.TIME_EXPIRED_KEY, str(profile.exp))
|
||||||
return profile
|
return profile
|
||||||
|
@ -184,6 +184,7 @@ async def login(
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
response.set_cookie(CONF.default.session_name, profile.toJWTPayload())
|
response.set_cookie(CONF.default.session_name, profile.toJWTPayload())
|
||||||
|
response.set_cookie(constants.TIME_EXPIRED_KEY, str(profile.exp))
|
||||||
return profile
|
return profile
|
||||||
|
|
||||||
|
|
||||||
@ -279,6 +280,7 @@ async def websso(
|
|||||||
else:
|
else:
|
||||||
response = RedirectResponse(url="/base/overview", status_code=status.HTTP_302_FOUND)
|
response = RedirectResponse(url="/base/overview", status_code=status.HTTP_302_FOUND)
|
||||||
response.set_cookie(CONF.default.session_name, profile.toJWTPayload())
|
response.set_cookie(CONF.default.session_name, profile.toJWTPayload())
|
||||||
|
response.set_cookie(constants.TIME_EXPIRED_KEY, str(profile.exp))
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
@ -378,4 +380,5 @@ async def switch_project(
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
response.set_cookie(CONF.default.session_name, profile.toJWTPayload())
|
response.set_cookie(CONF.default.session_name, profile.toJWTPayload())
|
||||||
|
response.set_cookie(constants.TIME_EXPIRED_KEY, str(profile.exp))
|
||||||
return profile
|
return profile
|
||||||
|
@ -66,3 +66,6 @@ SUPPORTED_SERVICE_EPS = {
|
|||||||
"trove": ["trove"],
|
"trove": ["trove"],
|
||||||
"zun": ["zun"],
|
"zun": ["zun"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Key of Time Expired in Cookie
|
||||||
|
TIME_EXPIRED_KEY = "time_expired"
|
||||||
|
Loading…
Reference in New Issue
Block a user