Skip to content

Commit 3f350f8

Browse files
committed
refac
1 parent 9d8f590 commit 3f350f8

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

backend/open_webui/config.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,12 @@ def __getattr__(self, key):
469469
os.environ.get("OPENID_PROVIDER_URL", ""),
470470
)
471471

472+
OPENID_END_SESSION_ENDPOINT = PersistentConfig(
473+
"OPENID_END_SESSION_ENDPOINT",
474+
"oauth.oidc.end_session_endpoint",
475+
os.environ.get("OPENID_END_SESSION_ENDPOINT", ""),
476+
)
477+
472478
OPENID_REDIRECT_URI = PersistentConfig(
473479
"OPENID_REDIRECT_URI",
474480
"oauth.oidc.redirect_uri",
@@ -844,13 +850,14 @@ def feishu_oauth_register(oauth: OAuth):
844850
if FEISHU_CLIENT_ID.value:
845851
configured_providers.append("Feishu")
846852

847-
if configured_providers and not OPENID_PROVIDER_URL.value:
853+
if configured_providers and not OPENID_PROVIDER_URL.value and not OPENID_END_SESSION_ENDPOINT.value:
848854
provider_list = ", ".join(configured_providers)
849855
log.warning(
850856
f"⚠️ OAuth providers configured ({provider_list}) but OPENID_PROVIDER_URL not set - logout will not work!"
851857
)
852858
log.warning(
853-
f"Set OPENID_PROVIDER_URL to your OAuth provider's OpenID Connect discovery endpoint to fix logout functionality."
859+
f"Set OPENID_PROVIDER_URL to your OAuth provider's OpenID Connect discovery endpoint,"
860+
f" or set OPENID_END_SESSION_ENDPOINT to a custom logout URL to fix logout functionality."
854861
)
855862

856863

backend/open_webui/routers/auths.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from fastapi.responses import RedirectResponse, Response, JSONResponse
4747
from open_webui.config import (
4848
OPENID_PROVIDER_URL,
49+
OPENID_END_SESSION_ENDPOINT,
4950
ENABLE_OAUTH_SIGNUP,
5051
ENABLE_LDAP,
5152
ENABLE_PASSWORD_AUTH,
@@ -824,6 +825,19 @@ async def signout(
824825
response.delete_cookie("oauth_session_id")
825826

826827
session = OAuthSessions.get_session_by_id(oauth_session_id, db=db)
828+
829+
# If a custom end_session_endpoint is configured (e.g. AWS Cognito), redirect
830+
# there directly instead of attempting OIDC discovery.
831+
if OPENID_END_SESSION_ENDPOINT.value:
832+
return JSONResponse(
833+
status_code=200,
834+
content={
835+
"status": True,
836+
"redirect_url": OPENID_END_SESSION_ENDPOINT.value,
837+
},
838+
headers=response.headers,
839+
)
840+
827841
oauth_server_metadata_url = (
828842
request.app.state.oauth_manager.get_server_metadata_url(session.provider)
829843
if session

0 commit comments

Comments
 (0)