fix; use timestamp for granted_at

pull/20494/head
GareArc 12 months ago
parent cb31b5e8b2
commit 743672f78d
No known key found for this signature in database

@ -115,11 +115,11 @@ def decode_enterprise_webapp_user_id(jwt_token: str | None):
# check if sso has been updated # check if sso has been updated
if auth_type == "external": if auth_type == "external":
last_update_time = EnterpriseService.get_app_sso_settings_last_update_time() last_update_time = EnterpriseService.get_app_sso_settings_last_update_time()
if granted_at and datetime.fromisoformat(granted_at) < last_update_time: if granted_at and datetime.fromtimestamp(granted_at, tz=UTC) < last_update_time:
raise Unauthorized("SSO settings have been updated. Please re-login.") raise Unauthorized("SSO settings have been updated. Please re-login.")
elif auth_type == "internal": elif auth_type == "internal":
last_update_time = EnterpriseService.get_workspace_sso_settings_last_update_time() last_update_time = EnterpriseService.get_workspace_sso_settings_last_update_time()
if granted_at and datetime.fromisoformat(granted_at) < last_update_time: if granted_at and datetime.fromtimestamp(granted_at, tz=UTC) < last_update_time:
raise Unauthorized("SSO settings have been updated. Please re-login.") raise Unauthorized("SSO settings have been updated. Please re-login.")
return decoded return decoded

@ -1,5 +1,6 @@
import random import random
from datetime import UTC, datetime, timedelta from datetime import UTC, datetime, timedelta
from time import time
from typing import Any, Optional, cast from typing import Any, Optional, cast
from werkzeug.exceptions import NotFound, Unauthorized from werkzeug.exceptions import NotFound, Unauthorized
@ -113,7 +114,7 @@ class WebAppAuthService:
"session_id": account.email, "session_id": account.email,
"token_source": "webapp_login_token", "token_source": "webapp_login_token",
"auth_type": "internal", "auth_type": "internal",
"granted_at": datetime.now(UTC).isoformat(), "granted_at": int(time()),
"exp": exp, "exp": exp,
} }

Loading…
Cancel
Save