From 00bd84944d9c6704fcdfd936db823b9579e3d9b3 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Tue, 17 Nov 2026 11:32:55 +0100 Subject: [PATCH] fix: log a warning when an OAuth session is deleted (#34583) Signing in past OAUTH_MAX_SESSIONS_PER_USER prunes a user's oldest stored OAuth sessions, a back-channel logout from the identity provider ends all of them, and connecting an MCP server again replaces the old session for that server. Pruning and the reconnect logged nothing, and the provider logout logged one info line per user without saying which sessions it removed, so an admin could not trace why a user's provider login was gone. Each of these deletions now logs a warning with the user, the session ID and the reason, the same way a failed token refresh already does. Fixes #34580 --- backend/open_webui/utils/oauth.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/backend/open_webui/utils/oauth.py b/backend/open_webui/utils/oauth.py index d6ead99354..ac326666fc 100644 --- a/backend/open_webui/utils/oauth.py +++ b/backend/open_webui/utils/oauth.py @@ -1346,6 +1346,12 @@ class OAuthClientManager: sessions = await OAuthSessions.get_sessions_by_user_id(user_id) for session in sessions: if session.provider == client_id: + log.warning( + 'Reconnect for user %s, client_id %s, deleting session %s', + user_id, + client_id, + session.id, + ) await OAuthSessions.delete_session_by_id(session.id) session = await OAuthSessions.create_session( @@ -2285,6 +2291,12 @@ class OAuthManager: # Keep the newest sessions up to the limit, prune the rest if len(provider_sessions) >= OAUTH_MAX_SESSIONS_PER_USER: for old_session in provider_sessions[OAUTH_MAX_SESSIONS_PER_USER - 1 :]: + log.warning( + 'Session limit reached for user %s, provider %s, deleting session %s', + user.id, + provider, + old_session.id, + ) await OAuthSessions.delete_session_by_id(old_session.id, db=db) session = await OAuthSessions.create_session( @@ -2517,6 +2529,12 @@ class OAuthManager: for user in users_to_logout: sessions = await OAuthSessions.get_sessions_by_user_id(user.id, db=db) for oauth_session in sessions: + log.warning( + 'Back-channel logout: user %s, provider %s, deleting session %s', + user.id, + oauth_session.provider, + oauth_session.id, + ) await OAuthSessions.delete_session_by_id(oauth_session.id, db=db) if redis: