This issue has been created
 
 
LLM AI Integration / cid:jira-generated-image-avatar-7985a353-f6ce-4597-8c63-1dbdf940dfba LLMAI-228 Open

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

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-e7061dfb-e317-4176-b05a-02bc2a2a88b3 GabrielC created this issue on 13/Nov/26 15:18
 
Summary: Allow the MCP endpoint to accept access tokens issued by an external OAuth authorization server
Issue Type: cid:jira-generated-image-avatar-7985a353-f6ce-4597-8c63-1dbdf940dfba New Feature
Affects Versions: 1.0.0
Assignee: Unassigned
Created: 13/Nov/26 15:18
Priority: cid:jira-generated-image-static-major-4d2d8872-aafe-44c9-b77a-9aad0a3a8ce5 Major
Reporter: GabrielC
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.