open-webui/backend/open_webui
Classic298 9db1a518d3
fix: refresh an expiring OAuth token once when requests race (#30426)
With an OIDC provider that rotates refresh tokens, sending a chat to a system_oauth connection often logged the user's OAuth session out. Two requests reached the refresh at the same time and both sent the same refresh token. The provider rejected the second one with invalid_grant, and Open WebUI deleted the session, so every following request lost its token until the user logged in again.

Refreshes now take a per-session lock. A request that waited for another one re-reads the session and uses the token that was just stored, so the provider sees one refresh per rotation.

Tested with real sqlite sessions and a rotating mock provider: 2 and 5 concurrent callers now cause 1 refresh, all callers get the new token and the session is kept (before: one refresh per caller, all callers got nothing, session deleted). Single refresh, failed refresh and valid-token paths are unchanged.

The lock is per process, so deployments with several workers or replicas can still race across processes.

Fixes #30416
2026-09-23 08:46:31 -05:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal refac 2026-09-06 17:13:32 -04:00
migrations chore: format 2026-08-25 16:53:53 -04:00
models refac 2026-09-22 13:13:22 -04:00
retrieval fix: page Chroma get() so hybrid search works on collections over 32k chunks (#30368) 2026-09-22 14:48:45 -04:00
routers refac 2026-09-22 13:13:22 -04:00
socket perf: per-room channel delivery for the socket.io Redis manager (#28818) 2026-09-22 14:48:56 -04:00
static refac 2026-09-06 17:27:30 -04:00
storage refac 2026-09-06 17:13:32 -04:00
tools refac 2026-09-21 08:59:39 -04:00
utils fix: refresh an expiring OAuth token once when requests race (#30426) 2026-09-23 08:46:31 -05:00
__init__.py perf: allow disabling websocket per-message-deflate (#28613) 2026-08-24 18:46:07 -04:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py refac 2026-09-21 11:09:09 -04:00
constants.py refac 2026-08-29 16:14:32 -04:00
env.py perf: per-room channel delivery for the socket.io Redis manager (#28818) 2026-09-22 14:48:56 -04:00
events.py refac 2026-08-16 23:21:00 -07:00
functions.py fix: honor bypass_system_prompt on the pipe route (#28739) 2026-08-19 11:08:02 -07:00
main.py refac 2026-09-21 08:59:39 -04:00
tasks.py refac 2026-09-21 08:59:39 -04:00