mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #22867] [CLOSED] feat: Add OAUTH_AUTHORIZE_PARAMS env var for extra OIDC authorization redirect parameters #26896
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/22867
Author: @rndmcnlly
Created: 3/19/2026
Status: ❌ Closed
Base:
dev← Head:feat/oauth-authorize-params📝 Commits (1)
966a033feat: add OAUTH_AUTHORIZE_PARAMS for extra OIDC authorization redirect params📊 Changes
2 files changed (+15 additions, -0 deletions)
View changed files
📝
backend/open_webui/config.py(+6 -0)📝
backend/open_webui/utils/oauth.py(+9 -0)📄 Description
Description
Adds
OAUTH_AUTHORIZE_PARAMS, a new environment variable that lets operators inject arbitrary extra query parameters into the OIDC authorization redirect URL — without code changes or a custom fork.Closes #22863
Problem
When Open WebUI uses an OIDC broker — a provider that itself presents a picker UI for choosing among upstream identity providers — the
/oauth/oidc/loginredirect drops users on the broker's full picker page. In deployments where only one upstream IdP is valid this causes two problems:OAUTH_ALLOWED_DOMAINSand receives a generic "Invalid credentials" error with no guidance. They completed what looked like a successful login.Every major OIDC broker provides a query parameter to pre-select or restrict the upstream IdP on the authorization endpoint:
idphint=<entityID>kc_idp_hint=<alias>connector_id=<id>There was previously no way to pass these through Open WebUI configuration.
Solution
OAUTH_AUTHORIZE_PARAMSaccepts a JSON object. Its entries are merged into the**kwargspassed to authlib'sclient.authorize_redirect()inhandle_login(), which passes them verbatim to the authorization URL query string.Example usage:
Implementation
backend/open_webui/config.py— newPersistentConfigalongsideOAUTH_AUDIENCE:backend/open_webui/utils/oauth.py— three additions: import, config wire-up, andhandle_loginlogic:Why this is small: authlib already passes
**kwargsverbatim throughauthorize_redirect()→create_authorization_url()→prepare_grant_uri()→ URL query string. The library does the right thing — OWUI just needed a way to populate those kwargs from config.Direct precedent:
OAUTH_AUDIENCE(PR #19768) uses this exact mechanism for a single hardcoded key. This generalises that pattern to an arbitrary JSON dict.Checklist
devbranchoidcprovider path — Google, Microsoft, GitHub, Feishu unaffectedOAUTH_AUDIENCEbehaviour unchangedTesting
Isolation tests (sandbox)
Full integration testing was not possible in the sandbox environment (1 GB cgroup memory limit prevents installing the complete dependency set). The following isolation tests were performed and all passed:
handle_loginkwargs block in isolation: empty/default (no-op),idphinthappy path, coexistence withOAUTH_AUDIENCE,acr_values, invalid JSON (warns, doesn't crash), JSON array (silently ignored)urllib.parse, matching authlib'sprepare_grant_uribehaviourOAUTH_AUTHORIZE_PARAMSIntegration test — CILogon with
idphint(human-verified)A local Open WebUI instance was started from this branch and configured with a CILogon OIDC client that has
http://localhost:8080/oauth/oidc/callbackas an allowed redirect:Results:
/oauth/oidc/loginendpoint redirected to CILogon withidphint=urn%3Amace%3Aincommon%3Aucsc.edupresent in the authorization URL query string.idphintfrom the authorization URL restored the full CILogon institution picker, confirming the parameter was responsible for the restriction. Logging in via a different institution (UC Irvine) also succeeded, confirming the feature does not break the standard flow.Changelog Entry
Added
OAUTH_AUTHORIZE_PARAMSenvironment variable: a JSON object of extra query parameters to append to the OIDC authorization redirect URL. Enables operators using OIDC brokers (CILogon, Keycloak, Dex, etc.) to pre-select or restrict the upstream identity provider without code changes. Invalid JSON is caught and logged as a warning; non-dict JSON is silently ignored. Only applies to the genericoidcprovider path.Additional Information
OAUTH_AUDIENCE— same mechanism, single hardcoded key)authorize_redirect(**kwargs)→create_authorization_url(**kwargs)→prepare_grant_uri(**kwargs)— kwargs become URL query params verbatim.Screenshots or Videos
N/A — the change is server-side only (no UI). Observable effect is the extra query parameters appearing in the browser's address bar during the OAuth redirect to the identity provider.
Contributor License Agreement
✨ Disclosure: this PR was researched and drafted using the Lathe coding agent toolkit inside of Open WebUI. The implementation, all test cases, and this description were reviewed and approved by the human author before submission.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.