-
Notifications
You must be signed in to change notification settings - Fork 3
Adjust ID token handling for proxy mode #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -586,7 +586,14 @@ func (h *OAuth2Handler) HandleToken(w http.ResponseWriter, r *http.Request) { | |||||
|
|
||||||
| // Add ID token if present | ||||||
| if idToken, ok := token.Extra("id_token").(string); ok { | ||||||
| response["id_token"] = idToken | ||||||
| if h.config.Mode == "proxy" { | ||||||
| // In proxy mode, trino-mcp is going to expect to receive id tokens | ||||||
| // that can be validated, not access tokens which can be opaque or | ||||||
| // from another issuer (e.g. Microsoft Graph when using Azure). | ||||||
| response["access_token"] = idToken | ||||||
| } else { | ||||||
| response["id_token"] = idToken | ||||||
| } | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix indentation inconsistency. Line 596 has excessive indentation (appears to use more spaces than the surrounding code). Apply this diff: - }
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| } | ||||||
|
|
||||||
| // Add scope if present | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Critical: Overwriting access_token with id_token violates OAuth2/OIDC semantics and discards the original access token.
In proxy mode, this change overwrites the
access_tokenfield (originally set on line 577) with theid_tokenvalue, which:access_tokenis for API authorization whileid_tokenis for authentication/identity verificationWhile this may resolve the immediate MCP-Trino verification issue, it creates a non-standard token response that could break other OAuth2 clients or integrations.
Alternative approaches to consider:
id_tokenfor verification in proxy modeverifiable_token) to avoid overwriting standard fieldsid_tokenfield rather thanaccess_tokenPlease verify the OAuth2/OIDC implications of this approach:
Additionally, run the following script to identify other potential consumers of the token endpoint:
🏁 Script executed:
Length of output: 7346
🌐 Web query:
💡 Result:
Short answer
Key semantic differences
Purpose
Audience / who consumes it
Format and semantics
Validation, revocation, and lifecycle
Security note
Sources
Critical: Code violates OAuth2/OIDC specification by substituting id_token for access_token.
Lines 589-596 in proxy mode overwrite the
access_tokenfield (set on line 577) with theid_tokenvalue. Per the OAuth2 and OIDC specifications, these tokens serve fundamentally different purposes and audiences:access_token: credential for API/resource server authorization; contains scope and permission informationid_token: authentication assertion for the client (relying party) containing identity claimsUsing an id_token as an access_token breaks the intended audience/validation model and can create security problems. This change:
Recommended fixes:
id_tokendirectly🤖 Prompt for AI Agents