mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[GH-ISSUE #22863] feat: Add OAUTH_AUTHORIZE_PARAMS env var for extra OIDC authorization redirect parameters #35359
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 @rndmcnlly on GitHub (Mar 19, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/22863
Problem Description
When Open WebUI is configured to use an OIDC broker — a provider that itself presents
a picker UI for choosing among multiple upstream identity providers — the
GET /oauth/oidc/loginredirect lands users on the broker's full picker page with noguidance. In deployments where only one upstream IdP is valid, this creates two
problems:
User confusion. The picker is unfamiliar and lists hundreds or thousands of
options (e.g. CILogon lists ~5,000 academic institutions). Users don't know what to
pick.
Silent wrong-IdP failure. A user who picks "Google" or another social IdP
authenticates successfully at the broker, then hits OWUI's
OAUTH_ALLOWED_DOMAINSgate and receives a generic "Invalid credentials" error — with no indication that
they chose the wrong IdP. They completed what looked like a successful login.
Every major OIDC broker provides a query parameter on the authorization endpoint to
pre-select or restrict the upstream IdP:
idphint=<entityID>kc_idp_hint=<alias>connector_id=<id>There is currently no way to inject these parameters through Open WebUI configuration.
Desired Solution
Add a single new environment variable
OAUTH_AUTHORIZE_PARAMSthat accepts a JSONobject. Its key/value pairs are merged into the
**kwargspassed to authlib'sclient.authorize_redirect()inhandle_login(), appending them as query parameterson the authorization redirect URL.
backend/open_webui/config.py— add alongsideOAUTH_AUDIENCE:backend/open_webui/utils/oauth.py— inhandle_login():Why this is trivially small: authlib's
authorize_redirectalready accepts andpasses
**kwargsverbatim throughcreate_authorization_url→prepare_grant_uri→ URL query string. The library already does the right thing — OWUI just needs to
surface a way to populate those kwargs from config. This was confirmed by reading the
authlib v1.6.6 source.
OAUTH_AUDIENCE(added in #19768) is the direct precedent,already using this exact mechanism for a single hardcoded key.
Example usage:
Alternatives Considered
One env var per known param (
OAUTH_IDP_HINT,OAUTH_LOGIN_HINT, etc.):Rejected — different brokers use different parameter names. A generic dict avoids
combinatorial growth and handles parameters we haven't anticipated.
OAUTH_ALLOWED_DOMAINSas the sole guard: Already works, but only as apost-authentication reject. The user experience of completing a login only to
receive "Invalid credentials" is poor. The goal is to prevent the wrong path
from being reachable at all.
Operator patches / custom fork: Defeats the purpose of a configurable
deployment.
Additional Context
authorize_redirect(**kwargs)→create_authorization_url(**kwargs)→prepare_grant_uri(**kwargs)— kwargs become URL query params verbatim.OAUTH_AUDIENCE/ PR #19768, same pattern.oidcprovider path (OAUTH_CLIENT_ID+OPENID_PROVIDER_URL). Google, Microsoft, GitHub, and Feishu providers areunaffected.
✨ Disclosure: issue researched and drafted using the Lathe coding agent toolkit inside of Open WebUI.
@tjbck commented on GitHub (Mar 24, 2026):
Addressed in dev!
@Classic298 commented on GitHub (Mar 24, 2026):
69171a4c8b