Skip to content

Using the built in auth router, the issuer URL is not fully utilized for the authorization endpoint #167

@localden

Description

@localden

Describe the bug

For example, I might want to be able to use the Microsoft Entra ID authorization experience:

app.use(mcpAuthRouter({
  provider: provider,
  issuerUrl: new URL('https://login.microsoftonline.com/TENANT_ID/v2.0'),
  serviceDocumentationUrl: new URL('https://den.dev'),
  authorizationOptions: {},
  tokenOptions: {}
}));

However, on the client side, when implementing OAuthClientProvider, this gets "cleaned" and only the domain makes it through, leading to an auth URL being something like this:

https://login.microsoftonline.com/authorize?response_type=code&client_id=SOMETHING_HERE&code_challenge=gEuH28apn6iVPB0hy5zCzpBzB13OXdpImHwp6y_W_JE&code_challenge_method=S256&redirect_uri=http%3A%2F%2Flocalhost%3A11780

Which will, of course, 404, since it doesn't exist.

This stems from the generated OAuth metadata (in /.well-known/oauth-authorization-server):

{
  "issuer": "https://login.microsoftonline.com/TENANT_ID/v2.0",
  "service_documentation": "https://den.dev/",
  "authorization_endpoint": "https://login.microsoftonline.com/authorize",
  "response_types_supported": [
    "code"
  ],
  "code_challenge_methods_supported": [
    "S256"
  ],
  "token_endpoint": "https://login.microsoftonline.com/token",
  "token_endpoint_auth_methods_supported": [
    "client_secret_post"
  ],
  "grant_types_supported": [
    "authorization_code",
    "refresh_token"
  ],
  "revocation_endpoint": "https://login.microsoftonline.com/revoke",
  "revocation_endpoint_auth_methods_supported": [
    "client_secret_post"
  ],
  "registration_endpoint": "https://login.microsoftonline.com/register"
}

Now, one might argue that mcpAuthRouter was not designed for other issuers, like Microsoft Entra ID, which would be fine. But I am curious if this is by-design behavior for integrating with third-party identity providers or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Significant bug affecting many users, highly requested featureauthIssues and PRs related to Authentication / OAuthbugSomething isn't workingready for workEnough information for someone to start working on

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions