mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
OAuth logout functionality fails to remove cookies with external domain SSO #3413
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 @TheDropZone on GitHub (Jan 24, 2025).
Bug Report
Installation Method
docker-compose deployment, with nginx proxy
Environment
Expected Behavior:
When using keycloak as the OAuth provider, after logging in, I see token and oauth_id_token cookies stored in my browser for the open-webui domain. When I click signout in the UI, both "token" and "oauth_id_token" cookies are removed from my browser (on open-webui domain) and I am redirected to my keycloak signout endpoint where I am signed out of keycloak.
Based on work done in keycloak signout MR: https://github.com/open-webui/open-webui/pull/7678
Actual Behavior:
When using keycloak as the OAuth provider, after logging in, I see token and oauth_id_token cookies stored in my browser for the open-webui domain. When I click signout in the UI, I am redirected to my keycloak signout endpoint where I am signed out of keycloak, but I see an error on the network redirect and the "token" and "oauth_id_token" cookies are still registered in my browser for open-webui domain
Description
So, I've deployed this OAuth functionality alongside a keycloak instance, and am running into some issues with the cookie deletion when open-webui and keycloak live on different domains.
The cookies (token, oauth_id_token) live and are set on the open-webui domain (openwebui01-domain.com), but the signout url from keycloak (and the openid_config) is on kc01-domain.com. So, it seems that when the signout endpoint requests to delete the cookies (living on openwebui01) but then redirects to kc01-domain for signout, the cookies don't get deleted (due to cookie domain mismatch). Because I'm redirected to the kc01-domain for the signout, the cookies dont exist at that domain to be deleted, and token and oauth_id_token live forever.
Reproduction Details
Logs and Screenshots
Browser Console Logs:
Docker Container Logs:
Additional Information
From initial debugging and adding log statements and such, I have validated that the signout code is executing correctly:
https://github.com/open-webui/open-webui/blob/main/backend/open_webui/routers/auths.py#L513
But, I have confirmed that the token and oauth_id_token values are stored on the open-webui domain, but the redirect sends me to the keycloak domain (which doesn't have the cookies, do to domain locking).
So, I'm not quite sure how to address this issue? It almost seems that the signout and cookie removal on open-webui would need to happen in a distinct and separate request chain than the logout call to keycloak?
@the-c0d3br34k3r commented on GitHub (Feb 9, 2025):
@TheDropZone, great job on documenting the steps in detail 🙌
It seems like a simple fix.
I've proposed the fix here
@tjbck commented on GitHub (Feb 18, 2025):
PR Welcome!
@the-c0d3br34k3r commented on GitHub (Feb 18, 2025):
Here it is - https://github.com/open-webui/open-webui/pull/10285