fix; use timestamp for granted_at

pull/20496/head
GareArc 12 months ago
parent 6ff1ab25d2
commit ed2941c696
No known key found for this signature in database

@ -97,11 +97,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 configs import dify_config from configs import dify_config
@ -109,7 +110,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