mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #22523] [CLOSED] feat: add trusted role header #26738
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/22523
Author: @dometto
Created: 3/10/2026
Status: ❌ Closed
Base:
dev← Head:add_trusted_role_header📝 Commits (10+)
fe6783cMerge pull request #19030 from open-webui/devfc05e0aMerge pull request #19405 from open-webui/deve3faec6Merge pull request #19416 from open-webui/dev9899293Merge pull request #19448 from open-webui/dev140605eMerge pull request #19462 from open-webui/dev6f1486fMerge pull request #19466 from open-webui/devd95f533Merge pull request #19729 from open-webui/deva7271530.6.43 (#20093)6adde20Merge pull request #20394 from open-webui/devf9b0534Merge pull request #20522 from open-webui/dev📊 Changes
3 files changed (+16 additions, -0 deletions)
View changed files
📝
backend/open_webui/env.py(+3 -0)📝
backend/open_webui/main.py(+2 -0)📝
backend/open_webui/routers/auths.py(+11 -0)📄 Description
Description
I've not opened a separate discussion because this feature was already requested, and I think improved, in https://github.com/open-webui/open-webui/issues/4858. In my opinion, however, that issue was wrongly closed without implementing the actually intended behavior (see here). Happy to open a new discussion if this is desired.
This PR implements the possibility to determine a user's role (admin, pending, user) at signin, using a trusted header. Open WebUI already has the possibility to handle authentication, and to set groups, using a trusted header. But a new user's role will, at present, always be equal to the
DEFAULT_USER_ROLEsetting. This means an identity provider cannot pass on info to Open WebUI on whether a user should be an admin or not.Implementation is very simple: in the
/signinroute, after checking for the trusted email header and before checking for the trusted groups header, we check for the presence of the configured trusted role header. The user's role is set to this role for the current session, and saved.Documentation
to be added
[ ] Add docs in Open WebUI Docs Repository. Document user-facing behavior, environment variables, public APIs/interfaces, or deployment steps.
Testing
I run
open-webuilocally usinguv, with the following environment variables:DEFAULT_USER_ROLE=user WEBUI_AUTH_TRUSTED_ROLE_HEADER=X-Remote-User-Role WEBUI_AUTH_TRUSTED_EMAIL_HEADER=X-Remote-User-Mail uv run open-webui serveTo test the trusted headers, I use the Chrome ModHeader extension.
See screengrab below for video.
Testing locally in Chrome:
testuser@localhostandX-Remote-User-Roletouserin ModHeader.http://localhost:8080testuser, as a normal user (despite being the first user -- trusted header trumps this).testuser2@localhostandX-Remote-User-Roletoadminin ModHeader.http://localhost:8080testuser2, with admin rights (the trusted header trumps the default role ofuser).X-Remote-User-Roleheader in ModHeader topending./. Observe thattestuser2is now pending.Changelog Entry
Added
🔒 Trusted header for user roles: the
WEBUI_AUTH_TRUSTED_ROLE_HEADERenvironment variable can be used to configure a trusted header that will determine the user's role (admin, user, or pending).Security
Additional Information
Screenshots or Videos
Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.