mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-29 08:31:48 -05:00
fix: OAuth connections send no token when the user calls the API (#32826)
A model connection with its auth type set to OAuth only forwarded the user's sign-in token for requests coming from the browser. The same user calling the API with their bearer token or an API key sent nothing upstream, so an SSO-protected model server rejected every API call and its models could not be listed or used. These connections now fall back to the user's latest sign-in session the same way tool servers already do. Fixes #32820
This commit is contained in:
1 parent
4ed1af6879
commit
6367a3cc40
1 file changed
+2
-10
@@ -19,6 +19,7 @@ from open_webui.env import (
|
||||
FORWARD_USER_INFO_HEADER_USER_ROLE,
|
||||
)
|
||||
from open_webui.models.groups import Groups
|
||||
from open_webui.utils.oauth import get_system_oauth_token
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -208,16 +209,7 @@ async def get_headers_and_cookies(
|
||||
elif auth_type == 'session':
|
||||
token = request.state.token.credentials
|
||||
elif auth_type == 'system_oauth':
|
||||
oauth_token = None
|
||||
try:
|
||||
if request.cookies.get('oauth_session_id', None):
|
||||
oauth_token = await request.app.state.oauth_manager.get_oauth_token(
|
||||
user.id,
|
||||
request.cookies.get('oauth_session_id', None),
|
||||
)
|
||||
except Exception as e:
|
||||
log.error(f'Error getting OAuth token: {e}')
|
||||
|
||||
oauth_token = await get_system_oauth_token(request, user) if user else None
|
||||
if oauth_token:
|
||||
token = f'{oauth_token.get("access_token", "")}'
|
||||
|
||||
|
||||
Reference in new issue
Block a user