mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 03:18:23 -05:00
[PR #8978] [MERGED] fix: Separate cookie configuration between session & auth cookies to prevent oauth flow from breaking #22299
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?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/8978
Author: @antpyykk-kone
Created: 1/27/2025
Status: ✅ Merged
Merged: 1/27/2025
Merged by: @tjbck
Base:
dev← Head:feature/separate-auth-cookie-config📝 Commits (1)
412923dfeat: separate cookie settings between session & auth cookies📊 Changes
3 files changed (+22 additions, -21 deletions)
View changed files
📝
backend/open_webui/env.py(+9 -8)📝
backend/open_webui/routers/auths.py(+8 -8)📝
backend/open_webui/utils/oauth.py(+5 -5)📄 Description
This PR introduces two new env variables to enable more granular control over cookie security setting. This is to fix an issue with the
WEBUI_SESSION_COOKIE_SAME_SITE, which could break the oauth flow when the value was set asstrictSetting the original SameSite config option as
strictincreases security by preventing cookies being accessed via cross-site requests. This is especially useful for authentication related cookies.However, the
strictmode would also prevent oauth flow from working, since the session cookie (oui-session) is required after a successful callback (see for example discussion https://github.com/open-webui/open-webui/discussions/4604)The underlying authlib would throw an error regarding
MismatchingStateErroras it could not access theoui-sessioncookie set by the SessionMiddleware.To still be able to use the
strictmode for auth cookies, while also enabling the session cookie being accessed after oauth callback, we introduce two new config options to control them in a more granular fashion.Pull Request Checklist
devbranch.Changelog Entry
Description
Added
WEBUI_AUTH_COOKIE_SAME_SITE&WEBUI_AUTH_COOKIE_SECUREto control auth related cookie securityWEBUI_SESSION_COOKIE_SAME_SITE&WEBUI_SESSION_COOKIE_SECUREas fallbacks to maintain backwards compatibilityChanged
WEBUI_AUTH_COOKIE_SAME_SITE&WEBUI_AUTH_COOKIE_SECUREconfiguration to controloauth_id_token&tokencookie security optionsAdditional Information
The original configuration options were most likely never intended to be used for all cookies.
af4f8aa). The config variable was clearly named with the intention to only control the session cookie's security.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.