Claus Ibsen created CAMEL-26356:
-----------------------------------
Summary: camel-mcp-server - OAuth for MCP clients: protected
resource metadata (RFC 9728), WWW-Authenticate and required scopes
Key: CAMEL-26356
URL: https://issues.apache.org/jira/browse/CAMEL-26356
Project: Camel
Issue Type: Improvement
Components: camel-mcp-server
Reporter: Claus Ibsen
Fix For: 4.24.0
On Camel Main and Camel JBang, {{/mcp}} can be protected with platform-http
authentication (basic or JWT). The token is checked, but a client gets a plain
401 and cannot find out where to get a token. The MCP authorization model
expects:
* protected resource metadata on {{/.well-known/oauth-protected-resource}},
naming the authorization server;
* {{WWW-Authenticate: Bearer resource_metadata="...", scope="..."}} on a 401,
and {{error="invalid_token"}} when a token was sent but rejected;
* 403 with {{error="insufficient_scope"}} when the token lacks a required scope.
With these, a standard MCP client runs the OAuth flow by itself, and a
standalone Camel MCP server works with an identity provider such as Keycloak
without any code.
h3. Proposal, for the Camel Main engine
* {{camel.server.mcp-oauth-profile}}, naming a camel-oauth named profile, the
same profiles platform-http's {{oauthProfile}} uses.
* Tokens are validated by that profile: signature, {{iss}}, {{aud}},
{{exp}}/{{nbf}} and the algorithm.
* The profile is checked at startup, so an incomplete profile or an unreachable
issuer stops the app.
* {{camel.server.mcp-required-scopes}}. The scopes are read from the {{scope}}
and {{scp}} claims.
* The metadata endpoint, served only when a profile is set:
{{authorization_servers}} is the profile's issuer, and {{scopes_supported}}
lists the required scopes.
* An identity provider that cannot be reached gives 503, not 401.
* The caller's subject, scopes and claims reach the route through
{{McpToolCallContext}}, alongside the principal name and roles from
CAMEL-25405, so an {{AuthorizationPolicy}} can check a scope.
* In stdio mode, which has no HTTP, the options are ignored with a WARN.
h3. Security review items
* {{error_description}} must not echo token or configuration values.
* The resource URL in the metadata must not be taken from client-supplied
{{Host}} / {{X-Forwarded-*}} headers unless the operator enables that.
On Spring Boot and Quarkus, the native security serves the metadata and checks
the scopes. The parity ticket covers passing the caller's identity on and
documenting that setup.
_Filed by Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)