Skip to content

fix OIDC discovery for issuers with trailing slash - #506

Open
karedum wants to merge 1 commit into
modelcontextprotocol:mainfrom
karedum:fix/oidc-discovery-trailing-slash
Open

fix OIDC discovery for issuers with trailing slash#506
karedum wants to merge 1 commit into
modelcontextprotocol:mainfrom
karedum:fix/oidc-discovery-trailing-slash

Conversation

@karedum

@karedum karedum commented Sep 12, 2026

Copy link
Copy Markdown

Preserve the original OIDC issuer for issuer validation and use a separate value without the trailing slash when constructing discovery URLs.

Motivation and Context

OidcDiscovery::fetchMetadata() currently removes the trailing slash from the configured issuer before performing discovery. The normalized value is also used for issuer validation.

This causes discovery to fail when the authorization server uses a trailing slash as part of its canonical issuer, such as Authentik.

OpenID Connect Discovery requires a terminating slash to be removed when constructing the discovery URL, while issuer validation must preserve the issuer identifier.

How Has This Been Tested?

Tested against an Authentik OAuth2/OpenID Connect provider whose issuer contains a trailing slash.

The existing test suite also passes locally.

Breaking Changes

None expected. Discovery URLs are constructed as before; the change only preserves the originally configured issuer for exact issuer validation.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant