mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[GH-ISSUE #23250] issue: oauth_session_id cookie never set due to undefined cookie_expires variable #35460
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pennycoders on GitHub (Mar 31, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/23250
Check Existing Issues
Installation Method
Docker
Open WebUI Version
v0.8.12
Operating System
macOS Sequoia 15.5 (Darwin 25.3.0)
Browser (if applicable)
Chrome 131
Confirmation
README.md.Expected Behavior
When a user logs in via OIDC (e.g., Authentik), the OAuth access token should be stored server-side and the
oauth_session_idcookie should be set in the browser. This allows thesystem_oauthauth_type for OpenAI API connections to forward the user's OIDC access token to upstream LLM providers.Actual Behavior
The
oauth_session_idcookie is never set. The OAuth session IS created in the database (viaOAuthSessions.create_session()), but the subsequentresponse.set_cookie()call raises aNameErrorbecausecookie_expiresis referenced but never defined. The exception is caught silently by the broadexcept Exceptionhandler.Error in logs:
Impact: The
system_oauthauth_type for OpenAI API connections is completely broken. When a user configures an OpenAI-compatible connection withauth_type: system_oauth, the code atrouters/openai.py:184tries to readoauth_session_idfrom cookies, finds nothing, and falls back to sending no Authorization header — defeating the purpose of OAuth token forwarding.Steps to Reproduce
ghcr.io/open-webui/open-webui:v0.8.12auth_type: system_oauthvia Admin → Settings → Connections → gear icon → Auth Type: OAuthoauth_session_idis absentLogs & Screenshots
Docker logs showing the error on every OIDC login:
Root cause in
backend/open_webui/utils/oauth.pyline 1686:The other
set_cookiecalls in the same function (lines 1637, 1648) correctly use onlymax_agewithoutexpires. Thecookie_expiresreference appears to be a copy-paste error.Additional Information
main(v0.8.12) anddevbranchescookie_max_ageis defined on line 1627 and is sufficient — browsers prefermax_ageoverexpiresper RFC 6265 §5.3'expires': cookie_expiresfrom the dict on line 1686@roller100 commented on GitHub (Apr 18, 2026):
Thanks to the Open WebUI team and to everyone who raised and narrowed this issue.
These threads were very helpful in tracking down and resolving our own authentication problems around
oauth_session_id/system_oauth.For anyone who is temporarily stuck on
v0.8.11/v0.8.12while the fix works its way through the normal release cycle, we wrote up the minimal interim hotfix we used here:https://github.com/BearingNode/bn-open-webui/issues/7
That note keeps the details public-safe and shows the smallest callback-path patch / Docker overlay we found useful in the interim.
Appreciate the issue reports and the fact that the fix is already tracked upstream.