-
Notifications
You must be signed in to change notification settings - Fork 111
implement flexible issuer validation for OIDC discovery #1825
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?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1825 +/- ##
==========================================
+ Coverage 42.59% 42.65% +0.05%
==========================================
Files 184 184
Lines 21775 21777 +2
==========================================
+ Hits 9276 9289 +13
+ Misses 11777 11770 -7
+ Partials 722 718 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
After talking to @amirejaz about the issue in more detail, it seems like the difference is typically in the issuer subdomain e.g. for |
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.
Pull Request Overview
This PR implements flexible issuer validation for OIDC discovery to resolve "issuer mismatch" errors that occur when MCP servers derive issuers from URLs but return different issuer values in their OIDC discovery documents.
- Adds
validateIssuerMatch
parameter to OIDC discovery functions to control issuer validation strictness - Tracks whether issuer was explicitly provided vs. derived from URL via new
IssuerProvided
field - Updates validation logic to skip issuer matching when issuer is derived (flexible validation)
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
pkg/runner/remote_auth.go | Adds tracking of whether issuer was explicitly provided and passes it to OAuth flow |
pkg/auth/oauth/oidc.go | Implements flexible issuer validation by adding validateIssuerMatch parameter to discovery functions |
pkg/auth/oauth/oidc_test.go | Updates tests to include validateIssuerMatch parameter and adds new test cases for flexible validation |
pkg/auth/oauth/dynamic_registration_test.go | Updates test call to use flexible validation (validateIssuerMatch=false) |
pkg/auth/discovery/discovery.go | Adds IssuerProvided field to OAuthFlowConfig and uses it to determine validation mode |
cmd/thv/app/proxy.go | Sets IssuerProvided field based on whether issuer was explicitly provided |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@@ -37,12 +37,18 @@ type httpClient interface { | |||
} | |||
|
|||
// DiscoverOIDCEndpoints discovers OAuth endpoints from an OIDC issuer | |||
func DiscoverOIDCEndpoints(ctx context.Context, issuer string) (*OIDCDiscoveryDocument, error) { | |||
return discoverOIDCEndpointsWithClient(ctx, issuer, nil) | |||
// Uses flexible issuer validation to support cases where issuer is derived from URL |
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.
[nitpick] The comment should end with a period for consistency with other function documentation.
// Uses flexible issuer validation to support cases where issuer is derived from URL | |
// Uses flexible issuer validation to support cases where issuer is derived from URL. |
Copilot uses AI. Check for mistakes.
When using dynamic client registration with some MCP servers, the system was failing with "issuer mismatch" errors because: