mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-12 23:02:35 +00:00
refac
This commit is contained in:
parent
ca8f151a12
commit
c1615bec2f
1 changed files with 9 additions and 1 deletions
|
|
@ -42,6 +42,7 @@ from open_webui.utils.access_control import has_permission
|
|||
from open_webui.utils.json_codec import JSONCodec
|
||||
from open_webui.utils.misc import parse_duration
|
||||
from pytz import UTC
|
||||
from redis.exceptions import RedisError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -254,8 +255,13 @@ async def is_valid_token(decoded, redis=None) -> bool:
|
|||
1. Per-token (jti) — used by user-initiated sign-out (known jti).
|
||||
2. Per-user (revoked_at) — used by password changes and OIDC back-channel
|
||||
logout when individual jti values are unknown; rejects tokens with iat <= revoked_at.
|
||||
|
||||
Fail open on Redis errors to preserve availability; revoked tokens may be accepted.
|
||||
"""
|
||||
if redis:
|
||||
if not redis:
|
||||
return True
|
||||
|
||||
try:
|
||||
# Per-token revocation
|
||||
jti = decoded.get('jti')
|
||||
if jti:
|
||||
|
|
@ -276,6 +282,8 @@ async def is_valid_token(decoded, redis=None) -> bool:
|
|||
return False
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
except RedisError as e:
|
||||
log.warning('Revocation check failed; accepting token: %s', e)
|
||||
|
||||
return True
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue