mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 11:28:35 -05:00
[GH-ISSUE #483] feat: OAuth/OIDC #27614
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 @Kryszn0 on GitHub (Jan 15, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/483
Is your feature request related to a problem? Please describe.
Add feature to enable account creation via OAuth/OIDC
Describe the solution you'd like
Integrating ollama-webui with auth providers such as Authentik, Keycloak, etc
Describe alternatives you've considered
N/A
Additional context
Being able to create a local account as an admin upon initialization should remain, but afterwards the admin account should be able to add the relevant information to change the default login page to redirect to a self-hosted OAuth/OIDC provider
@tjbck commented on GitHub (Jan 15, 2024):
Related: #340
@mafrasiabi commented on GitHub (Jan 19, 2024):
It would be very good to have integration with AzureAD too.
@josh commented on GitHub (Jan 28, 2024):
Ever since the new user accounts were rolled out, I've been wanting some kind of way to delegate auth as well.
In my specific case, my ollama-webui is behind a Tailscale VPN. They have a pretty lightweight set of trusted identity headers when proxied to. It seems like a few other SSO providers like Authelia can be configured to pass along trusted headers.
From the ollama-webui side, you'd configure some envvar like
OLLAMA_AUTH_TRUSTED_HEADER=X-Remote-Userto enable this delegated auth mode. The Python backend would look for this header and automatically log in or create an account for the user given in the header value.I wondering if this approach would cover your auth use cases as well? If so, I might take a stab at a PR implementation.
@explorigin commented on GitHub (Feb 9, 2024):
Just a heads up. I'm working on integrating https://fastapi-users.github.io/fastapi-users/latest/ into ollama-webui. That will give us OAUTH2 for these clients: https://frankie567.github.io/httpx-oauth/oauth2/#provided-clients. Give me a few weeks.
@elvis-cai commented on GitHub (Feb 26, 2024):
thanks @explorigin 🙇 it will be a killer feature in the open llm UI market.
I am keen to have this feature for demo in the coming weeks, if you don't mind, Could I know if there's any estimation for it available?
@explorigin commented on GitHub (Feb 26, 2024):
Sorry, no estimate. I started on it but work/life got crazy. If you need it for work then work on it. I've started with fastapi-users library but that has some considerations:
And that's all before getting to the Oauth configuration that needs to be exposed in a smart manner. So it's not a simple feature.
@aitzubi commented on GitHub (Mar 7, 2024):
I will be interested on testing this when it is available. It would be great to add an option to automatically verify users based on their domain.
Keep the good job guys!
@m00nwtchr commented on GitHub (Mar 10, 2024):
+1 for auth via Forwarded Headers, for many selfhosted setups OIDC/OAuth is pretty overkill. (Though still very useful for public instances)
@cheahjs commented on GitHub (Mar 26, 2024):
Not quite what was asked for with OAuth/OIDC for the actual auth, but I've yolo'd in a patch for my own use case with trusted headers, https://github.com/open-webui/open-webui/compare/dev...cheahjs:open-webui-fork:feat/trusted-email-header
Users will still have to enter their email addresses to sign up and sign in(I've implemented automatic registration and sign in for users that have been authed by the header), but I've tested it withWEBUI_AUTH_TRUSTED_EMAIL_HEADER=Tailscale-User-Loginfor Tailscale Serve, andWEBUI_AUTH_TRUSTED_EMAIL_HEADER=X-WebAuth-Userwith gcp-iap-auth + Google Clouds's Identity Aware Proxy@explorigin commented on GitHub (Mar 26, 2024):
Yep, I announced and then ghosted. Sorry. Going through a job change. Don't count on me for this.
@cheahjs commented on GitHub (Apr 3, 2024):
Given the newly merged trusted email header feature, Open WebUI doesn't support federated auth by itself, but it can offload auth to a authenticating proxy. Some example compose stacks (these are not exactly production ready, remember to harden where necessary with your own secrets):
Tailscale Serve
Starts Tailscale as a sidecar, and exposes Open WebUI via Tailscale Serve. Authorization should be handled using your tailnet's ACL rules.
docker-compose.yaml
tailscale-serve.json
oauth2-proxy
oauth2-proxysupports multiple OAuth providers and OIDC (list of providers). You will need to configure the providers and how to handle authorization yourself. I have not tested this.docker-compose.yaml
oauth2-proxy.cfg
oauth2-proxy.yaml
For anyone running Open WebUI inside of GCP, I've deployed Identity Aware Proxy with gcp-iap-auth as a reverse proxy to extract the email from the JWT.
@tjbck commented on GitHub (Apr 3, 2024):
@cheahjs I believe a lot of people would find this tutorial useful, if you could make a PR here: https://github.com/open-webui/docs, we'd greatly appreciate it! Thanks for all the effort to make Open WebUI even better thus far!
@Michelklingler commented on GitHub (Apr 3, 2024):
I agree super well done documentation!
Thanks a lot!
@cellulosa commented on GitHub (Apr 4, 2024):
any luck setting this up with Authelia?
@cheahjs commented on GitHub (Apr 4, 2024):
I don't currently have time to test out an Authelia deployment, but the docs for setting up the necessary headers is over at https://www.authelia.com/integration/trusted-header-sso/introduction/
@AsteroidOrangeJuice commented on GitHub (Apr 6, 2024):
@cellulosa I can confirm this works with Authelia with the Remote-Email header too! Thanks @cheahjs !!
@sammcj commented on GitHub (Apr 6, 2024):
Confirmed I've got this working with Traefik + Authentik 🎉
Large example available here: https://github.com/open-webui/open-webui/issues/929#issuecomment-2041296801
@cellulosa commented on GitHub (Apr 9, 2024):
could you share your config? Thanks!Nevermind, I managed! For all those interested:
Set the email header in
open-webuiin thedocker-composefile:Make sure to pass it in the
Caddyfile:Were
{$MY_DOMAIN}can be hardcoded or passed as passed via docker-compose as:@eingemaischt commented on GitHub (Apr 10, 2024):
This sound absolutely fantastic! Is it possible to transmit the users role (admin, user etc) as trusted header, too?
@aitzubi commented on GitHub (Apr 29, 2024):
Anybody knows how to implement this using Keycloak?
@Michelklingler commented on GitHub (Apr 29, 2024):
On my Side Woking well with Oauth2-proxy.
Only issue is that I can't log out for some reason.
Below is the working config to add to your docker compose:
@hkng commented on GitHub (May 1, 2024):
For oauth2-proxy and keycloak, logout can be done by following url
Refer to /src/routes/(app)/prompts/+layout.svelte, If we can find a way to change sign-out button as below, it may solve logout problem
@sammcj commented on GitHub (May 8, 2024):
re: https://github.com/open-webui/open-webui/issues/483#issuecomment-2041216612
FYI Authentik auth seems to now be broken with the release of v0.1.124.
Tried with both the same config as I had for v0.1.123 (auth enabled), and with a fresh deployment with empty DB etc... and auth disabled.
I suspect it has something to do with this: https://github.com/open-webui/open-webui/issues/929#issuecomment-2101623934
@tjbck commented on GitHub (May 8, 2024):
@sammcj Just pushed a fix for trusted header support, let me know if the issue persists!
@sammcj commented on GitHub (May 8, 2024):
comment moved to https://github.com/open-webui/open-webui/issues/929#issuecomment-2101667151
@NathanAdhitya commented on GitHub (May 20, 2024):
As mentioned by hkng, I think a post-logout redirect is needed.
Currently, with oauth2-proxy, the sign out button does not work.
For the sake of completeness, a mechanism to correctly change the user when the user of the current token mismatches the trusted email header would be nice. As of now, changing the header value does not cause open-webui to change user until the sign out button is clicked.
@Macmee commented on GitHub (May 26, 2024):
Hi! I was wondering if oauth2-proxy is still working (or probably im just setting it up wrong!)
when I visit mydomain.com/oauth2/auth I can see these headers:
and ive tried setting both of these in docker-compose like:
So I think my headers are getting set, but when I visit openwebui I see:
@LopezRoman commented on GitHub (Jun 6, 2024):
Is there a way to redirect the user after a successful authentication using
WEBUI_AUTH_TRUSTED_EMAIL_HEADER?For example, I have my Open WebUI embedded in an html block of a Moodle instance (seperate server) which utilizes a PHP script to call
http://localhost:3001/api/v1/auths/signinwith the appropriate post, headers, and json data however I am not redirected. I do see the user created and I am returned the new user data (username, email, token, etc.), just no redirect. I am not using tailescale nor cloudlfar, just the generic configurationl@keesfluitman commented on GitHub (Jul 3, 2024):
im confused. The Documentation says a lot about ENV variables for OAuth. For instance:
ENABLE_OAUTH_SIGNUP
OAUTH_CLIENT_SECRET
etc.
Yet when I add my Authentik OAuth settings in there. Nothing happens. And considering the lack of topics about this, Im confused as to if it actually even exists?
Why does it say it here?
https://docs.openwebui.com/getting-started/env-configuration/#oauth
@ProjectMoon commented on GitHub (Jul 11, 2024):
I'm trying to set this up with Authelia. It redirects to Authelia fine, but the redirect URL for OpenWebUI itself is always
http://instead ofhttps://. I have session cookie security set to secure, which makes the oauth clienthttps_only. Why would it attempt to callback to an HTTP URL?Edit: answered my own question. Needed to make sure that the HTTP protocol was forwarded in nginx.
@christiangierschner commented on GitHub (Jul 23, 2024):
Hi,
I successfully set up OAUTH with Keycloak. Is there a way to disable the native open-webui login and get redirected straight to Keycloak. So users don't get confused or don't use the button below the login fields?
@Louden7 commented on GitHub (Jul 25, 2024):
@christiangierschner check out #4068 as it might satisfy your request.
@christiangierschner commented on GitHub (Jul 25, 2024):
Nice! Thank you so much...i will try it
I would love an automatic forward to OAuth when opening webui url if
@keesfluitman commented on GitHub (Jul 28, 2024):
OAUTH i get a middleware error. Using Authentik. Everything should be right but nothing works.
Trusted header works partly, it logs in, but then doesn't use the received token to further request.
Can anyone help me? Im at a loss here. I read about how easy it is, etc. But it's just refusing to work.
@senpro-ingwersenk commented on GitHub (Aug 1, 2024):
@christiangierschner Mind sharing your settings? Running into this:
(Context: Test server running in plain HTTP vs. Keycloak in Kubernetes in HTTPS, not sure if it matters or not...)
The error that I see on screen is:
Thanks!
@christiangierschner commented on GitHub (Aug 6, 2024):
i didnt do any magic it worked right out of the box...
we have a docker host with traefik + local acme for https certificate
@Lanhild commented on GitHub (Aug 13, 2024):
Works for me using Open WebUI w/ Docker (on Cloudron) and Authentik. Simply create your app and provider in Authentik, then fill in the variables:
@atnjqt commented on GitHub (Aug 20, 2024):
For folks using a more traditional setup of SAML authentication with Apache & Shibboleth on Linux, I'm wondering if there is a use case or mechanism for exposing Shibboleth attributes as the trusted headers!
@brtptrs commented on GitHub (Aug 21, 2024):
@senpro-ingwersenk did you solve your problem?
I am seeing the same error response when trying to authenticate via oidc (Keycloak)
@senpro-ingwersenk commented on GitHub (Aug 22, 2024):
@brtptrs Sadly no I am afraid... Haven't had an idea how to debug it either - my last resort would've been to drop wireshark between the two and see what comes out. But other than that I am rather clueless to be honest. The other thing I might try is to make Traefik in our k3s cluster be more detailed for Keycloak - in terms of access logs. Maybe this tells me something...? Other than that, I have no real idea tbh ^^;
@brtptrs commented on GitHub (Aug 22, 2024):
Thanks for the feedback.
I've enabled debugging and am seeing these entries in the logs:
INFO: 79.220.58.87:0 - "GET /oauth/oidc/login HTTP/1.1" 302 Found
DEBUG [main] Commit session after request
INFO: 79.220.58.87:0 - "GET /oauth/oidc/callback?state=xxxxxxxxxxxxxxxxx&session_state=cabdac81-yyyyyyyyyyyyyyy&code=zzzzzzzzzzzzzzzzzzzzzz.cabdac81-yyyyyyyyyyyyyyy.qqqqqqqqqq HTTP/1.1" 307 Temporary Redirect
WARNI [main] OAuth callback error: mismatching_state: CSRF Warning! State not equal in request and response.
DEBUG [main] Commit session after request
INFO: 79.220.58.87:0 - "GET /oauth/oidc/callback?state=xxxxxxxxxxxxxxxxx&session_state=cabdac81-yyyyyyyyyyyyyyy&code=zzzzzzzzzzzzzzzzzzzzzz.cabdac81-yyyyyyyyyyyyyyy.qqqqqqqqqq HTTP/1.1" 400 Bad Request
Unfortunately, I don't know what to make of it.
On our setup, OpenWebui is running in a docker container behind an Apache reverse -proxy. Maybe that has something to do with the problem.
On oidc login, the user is correctly redirected to KeyCloak and then back to OpenWebUI after a successful login.
Maybe we should open a new ticket for this.
@aeonoea commented on GitHub (Aug 23, 2024):
@Macmee Have you ever figured out a solution? I am getting the same answer from my Synology SSO server using OIDC service:
{ "detail": "You do not have permission to access this resource. Please contact your administrator for assistance." }I set the following scopes according to the specifications of the server. Everything else including the default scopes would give me an internal server error.
- OAUTH_SCOPES=openid email usernameedit: silly me, I forgot to add the environment variable to enable oauth, and it works now:
ENABLE_OAUTH_SIGNUP=true@utilitee commented on GitHub (Aug 31, 2024):
In my case (Openwebui+Nginx Proxy Manager+Oauth2-proxy) I just use Advance host config
logic is if user requested to ai.mydomain.com/auth then redirect to ai.mydomain.com/oauth2/sign_out. working fine didn't see issue yet. let me know if you got better one.
@luochen1990 commented on GitHub (Sep 3, 2024):
For me, user have to clear cache after successfully register and before first login, otherwise the web page will keep refresh, still not knowing why
@emgitadm commented on GitHub (Oct 4, 2024):
@emgitadm commented on GitHub (Oct 4, 2024):
Where and how can I set the variables? my setup is using docker hosted on a virtual machine (local machine and Authentik?
@dongsupkim-onepredict commented on GitHub (Oct 6, 2024):
@emgitadm with environment variable
@nwithan8 commented on GitHub (Oct 14, 2024):
Can you elaborate on this? Running into the same issue. Do I need to do something at the proxy level (HAProxy running on pfSense)? I haven't had to do that for other apps using Authentik for OIDC all going out the main pipe (external domains rather than internal IPs)
@alimaskin commented on GitHub (Nov 12, 2024):
Hi @christiangierschner, were you able to achieve the desired result with the automatic redirect to Keycloak when opening the Open WebUI URL? Thank you!"
@phyzical commented on GitHub (Dec 11, 2024):
I was wondering this too, that last thing missing is an "auto login"/ "auto redirect" to auto trigger the OIDC flow
@christiangierschner commented on GitHub (Jan 6, 2025):
Hi, Unfortunately not. Our Users have to click on the login button...would love this though...
@voc0der commented on GitHub (Jan 16, 2025):
Same here
@atnjqt commented on GitHub (Jan 16, 2025):
@phyzical & @christiangierschner I've gotten around this auto-login functionality with implementing a passive Shibboleth & Apache reverse proxy setup.
For all routes besides
/auth(and also the/faviconwhich was throwing some strange CORS errors in browser console) this is setup passively.A new user hits my app, the app seemingly redirects the frontend to
/auth_ but this isn't actually a 301 or 302 redirection to the backend proxy.Thus the user needs to refresh the page on
/authone time, which then hits the proxy as my only active shibboleth route, which initiates the call to the IDP which then returns the necessary RequestHeaders I'm mapping to env vars for authorized email domains. I imagine the OIDC flow is similar to a Shibboleth setup!Really if the app did a proper redirect to that
/authroute, instead of just updating the client-side browser URL to have this, it'd work like a login!Here is a sample of that apache config:
@arunbugkiller commented on GitHub (Feb 14, 2025):
I think you would be able to solve most of the problems with below environment variables. Please do try it out
-e ENABLE_OAUTH_SIGNUP=true -e WEBUI_SESSION_COOKIE_SAME_SITE=lax -e WEBUI_AUTH_COOKIE_SAME_SITE=lax -e ENABLE_LOGIN_FORM=True -e OAUTH_MERGE_ACCOUNTS_BY_EMAIL=true