mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-28 06:22:33 +00: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:
parent
4ed1af6879
commit
6367a3cc40
1 changed files with 2 additions and 10 deletions
|
|
@ -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", "")}'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue