fix(sso): handle opaque access tokens in process_sso_jwt_access_token#20726
Merged
krrishdholakia merged 1 commit intoBerriAI:litellm_oss_staging_02_09_2026from Feb 10, 2026
Conversation
OIDC providers like Logto may return opaque (non-JWT) access tokens, which caused jwt.decode() to raise DecodeError and crash the SSO callback with a 500 error. Catch DecodeError and skip JWT-based extraction gracefully, since user info is already available from the UserInfo endpoint. Fixes BerriAI#20724
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile OverviewGreptile SummaryFixes a 500 error crash on the
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/proxy/management_endpoints/ui_sso.py | Wraps jwt.decode() in try-except to handle opaque (non-JWT) tokens gracefully, fixing crash on /sso/callback endpoint |
| tests/test_litellm/proxy/management_endpoints/test_ui_sso.py | Removes obsolete mock-based tests, adds real JWT tests for opaque token handling and improved exception test accuracy |
Sequence Diagram
sequenceDiagram
participant Client
participant SSO_Callback as /sso/callback
participant process_sso_jwt as process_sso_jwt_access_token()
participant JWT_Lib as jwt.decode()
participant UserInfo as UserInfo Endpoint
Client->>SSO_Callback: OAuth callback with access_token
SSO_Callback->>UserInfo: Fetch user info (team IDs, role)
UserInfo-->>SSO_Callback: User info extracted
SSO_Callback->>process_sso_jwt: Extract additional claims from access_token
alt Access token is a valid JWT
process_sso_jwt->>JWT_Lib: Decode token (verify_signature=false)
JWT_Lib-->>process_sso_jwt: JWT payload
process_sso_jwt->>process_sso_jwt: Extract team_ids (via sso_jwt_handler)
process_sso_jwt->>process_sso_jwt: Extract user_role (if not in UserInfo)
process_sso_jwt-->>SSO_Callback: Updated result with JWT claims
else Access token is opaque (non-JWT)
process_sso_jwt->>JWT_Lib: Attempt decode
JWT_Lib-->>process_sso_jwt: DecodeError
Note over process_sso_jwt: Catch DecodeError, log debug, return early
process_sso_jwt-->>SSO_Callback: Result unchanged (UserInfo data only)
end
SSO_Callback-->>Client: Authentication success
Contributor
Author
|
Would it be possible to prioritize reviewing and merging this PR? The issue caused by #20724 blocks all SSO through IdPs that do not use JWT Access Tokens, so this may be considered a fairly severe and urgent issue. |
Contributor
|
Think it could solve a issue I saw last Friday and I revert back to an old version due to another bug but didn’t get time to investigate @krrishdholakia @ishaan-jaff |
5d4cef2
into
BerriAI:litellm_oss_staging_02_09_2026
7 of 8 checks passed
Sameerlite
pushed a commit
that referenced
this pull request
Feb 10, 2026
…#20726) OIDC providers like Logto may return opaque (non-JWT) access tokens, which caused jwt.decode() to raise DecodeError and crash the SSO callback with a 500 error. Catch DecodeError and skip JWT-based extraction gracefully, since user info is already available from the UserInfo endpoint. Fixes #20724
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relevant issues
Fixes #20724
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unitCI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
🐛 Bug Fix
Changes
sso_jwt_handlerguard inprocess_sso_jwt_access_token(), causingjwt.decode()to run unconditionally on all access tokens. OIDC providers that return opaque (non-JWT) tokens (e.g. Logto) trigger a DecodeError, crashing the/sso/callbackendpoint with a 500 error.jwt.decode()in atry-except jwt.exceptions.DecodeErrorand return early when the token is not a valid JWT. This is safe because user info (team IDs, role) is already extracted from the UserInfo endpoint ingeneric_response_convertor(); the JWT access token extraction is only a supplementary source for providers like Keycloak that embed claims in the access token.