Uploaded image for project: 'LLM AI Integration'
  1. LLM AI Integration
  2. LLMAI-228

Allow the MCP endpoint to accept access tokens issued by an external OAuth authorization server

    XMLWordPrintable

Details

    • New Feature
    • Resolution: Unresolved
    • Minor
    • None
    • 1.0.0
    • None
    • Unknown

    Description

      Context

      The MCP endpoint (/rest/wikis/<wiki>/aiLLM/mcp) lists the wiki's own OIDC Provider (<webapp>/oidc) as its only authorization server in the protected-resource metadata (DefaultMCPResource#buildOidcIssuerUrl). It honors bearer tokens only when the active authenticator is the OIDC Provider's token bridge (oidc-provider-bridge), which accepts only tokens that the wiki's provider issued.

      On a wiki that signs users in through an organization's identity provider (Keycloak, Entra ID, Okta), an agent therefore gets a second token from the wiki, with its own consent step, lifetime and revocation. A token issued by the identity provider is refused with 401.

      The JWTTokenAuth authenticator of this project does not cover this case. It verifies Ed25519 signatures with a key configured per authorized application rather than the issuer's JWKS, it maps tokens to its own user pages instead of the users the OpenID Connect Authenticator creates, and the MCP endpoint does not recognize it, so no OAuth discovery is offered.

      Proposal

      The MCP authorization specification allows the authorization server to be a third party. Make it configurable per wiki:

      • A setting that names an external authorization server (its issuer URL). When it is set, the protected-resource metadata lists that issuer in authorization_servers, and the 401 challenge points to the metadata as it does today.
      • An authenticator, or an extension of the existing token bridge, that validates the identity provider's access tokens: the JWT signature against the issuer's JWKS, iss, exp, and an aud that matches the MCP endpoint (RFC 8707 resource indicators, which the MCP specification requires). Token introspection (RFC 7662) covers opaque tokens.
      • Map the token's subject to the wiki user that the OpenID Connect Authenticator creates for that issuer and subject (XWiki.OIDC.UserClass), so an agent acts as the same user as the browser login.

      Considerations

      • Clients register with the identity provider instead of the wiki. Keycloak supports dynamic client registration. Entra ID does not, so clients need a pre-registered client ID.
      • The identity provider must issue tokens with the MCP endpoint as audience, for example with an audience mapper in Keycloak or an exposed API in an Entra ID app registration.
      • Token validation might belong in the OIDC extension, as a token authenticator for upstream identity provider tokens, with the MCP endpoint only advertising the issuer.

      With this, token lifetime, refresh, revocation and MFA follow the identity provider's policies, and disabling a user there also cuts off their agents. Related: the OIDC issue about the lifetime of tokens issued by the provider.

      Attachments

        Activity

          People

            Unassigned Unassigned
            gabrielc GabrielC
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: