Federico Mariani created CAMEL-27120:
----------------------------------------
Summary: camel-oauth, camel-spiffe - call services and LLM
providers without static secrets and on behalf of the user: token exchange,
step-up, SPIFFE workload identity
Key: CAMEL-27120
URL: https://issues.apache.org/jira/browse/CAMEL-27120
Project: Camel
Issue Type: New Feature
Components: camel-mcp-server, camel-oauth, camel-http, camel-spiffe,
camel-openai
Reporter: Federico Mariani
h2. Goal
Camel integrations and AI agents should call other services and LLM providers
*without static secrets* (API keys, client secrets) and, when they act for a
user, *with that user's identity* instead of a shared service token. Two
families of standards cover this:
* *Delegation.* A resource server that calls another API for its caller
exchanges the caller's token (RFC 8693 token exchange) instead of forwarding
it: the MCP authorization specification forbids token passthrough. A sensitive
operation can require a stronger or more recent user authentication (RFC 9470
step-up).
* *Workload identity.* A workload proves who it is with a short-lived SPIFFE
JWT-SVID: as client authentication at the authorization server (RFC 7523
section 2.2, draft-ietf-oauth-spiffe-client-auth, available in Keycloak as a
preview feature), as the JWT bearer grant of a workload identity federation to
obtain an LLM provider token (RFC 7523 section 2.1), or directly as the bearer
token of a call to another workload.
h2. Where Camel stands
* camel-mcp-server validates OAuth bearer tokens (RFC 9728 metadata, required
scopes) and ai-tool routes can be guarded by an {{AuthorizationPolicy}}.
* camel-oauth validates incoming tokens and obtains client credentials tokens,
with a client secret only.
* camel-spiffe fetches and validates X.509 and JWT SVIDs, and provides SPIFFE
mTLS and authorization policies.
* Missing: token exchange, assertion based client authentication, the JWT
bearer grant, step-up, and a way for an HTTP producer to use them for each
exchange. Also, the AI components resolve their {{oauthProfile}} token only
once at startup, so short-lived tokens stop working when they expire (linked
bug).
h2. Proposal
Configuration only, reusing the existing components:
* camel-oauth client profiles gain the token exchange, JWT bearer and assertion
grants, and client authentication with an assertion;
* camel-spiffe provides the workload JWT-SVID as that assertion (a bean);
* camel-http gains an {{oauthProfile}} option resolved for each exchange;
* camel-oauth validation profiles gain {{retain-token}} (keep the caller token
on the exchange so it can be exchanged, never in a header) and step-up options.
h3. Example 1: MCP server acting for the user, without a client secret
The user token sent by the chat application (audience: the MCP server) is
validated and kept; a tool route calls the downstream API with a token
exchanged on behalf of that user. The MCP server authenticates to the
authorization server with its JWT-SVID.
{code}
camel.server.mcp-oauth-profile = users
camel.beans.spiffeJwt =
#class:org.apache.camel.component.spiffe.SpiffeJwtSvidAssertionProvider
camel.oauth.users.base-uri = https://idp.example.com/realms/demo
camel.oauth.users.expected-audience = mcp-server-api
camel.oauth.users.retain-token = true
camel.oauth.on-behalf-of-user.grant-type = token-exchange
camel.oauth.on-behalf-of-user.token-endpoint =
https://idp.example.com/realms/demo/protocol/openid-connect/token
camel.oauth.on-behalf-of-user.client-assertion-provider = #spiffeJwt
camel.oauth.on-behalf-of-user.client-assertion-type = jwt-spiffe
camel.oauth.on-behalf-of-user.client-assertion-audience =
https://idp.example.com/realms/demo
camel.oauth.on-behalf-of-user.audience = conference-api
# calling another workload as itself: the JWT-SVID is the bearer token
camel.oauth.as-workload.grant-type = assertion
camel.oauth.as-workload.assertion-provider = #spiffeJwt
camel.oauth.as-workload.assertion-audience = spiffe://example.org/conference-api
{code}
{code:yaml}
- route:
from:
uri: ai-tool:my_sessions
parameters:
tags: conference
description: "List the conference sessions of the signed-in user"
steps:
- removeHeaders:
pattern: "*"
- to:
uri: https://api.example.com/api/my-sessions
parameters:
oauthProfile: on-behalf-of-user
{code}
The downstream API (a {{platform-http}} route with its own {{oauthProfile}})
receives a token with {{sub}} = the user, {{aud}} = conference-api and {{azp}}
= mcp-server: it applies the user's permissions and audits who acted through
whom. The identity used downstream is decided by the endpoint configuration,
never by the model or by a message header.
h3. Example 2: agent calling an LLM without an API key
{code}
camel.beans.spiffeJwt =
#class:org.apache.camel.component.spiffe.SpiffeJwtSvidAssertionProvider
camel.oauth.llm.grant-type = jwt-bearer
camel.oauth.llm.token-endpoint = https://api.anthropic.com/v1/oauth/token
camel.oauth.llm.token-request-format = json
camel.oauth.llm.client-authentication = none
camel.oauth.llm.assertion-provider = #spiffeJwt
camel.oauth.llm.assertion-audience = https://api.anthropic.com
camel.oauth.llm.extra-parameter.federation_rule_id = fdrl_...
camel.oauth.llm.extra-parameter.organization_id = ...
camel.oauth.llm.extra-parameter.service_account_id = svac_...
{code}
{code:yaml}
- to:
uri: openai:chat-completion
parameters:
oauthProfile: llm
baseUrl: "https://..."
model: "..."
{code}
The provider token is short-lived and obtained again before it expires. The LLM
call itself is the OpenAI API of camel-openai, so any OpenAI compatible
endpoint works; only the token profile depends on the provider. OpenAI's own
workload identity federation uses RFC 8693 token exchange with the workload JWT
as subject token ({{https://auth.openai.com/oauth/token}},
{{identity_provider_id}}, {{service_account_id}}), covered by a subject token
provider in the camel-oauth sub-task.
h2. Validation
A prototype of the sub-tasks was run against SPIRE 1.15.3 with the OIDC
Discovery Provider and Keycloak 26.8.2 with the {{spiffe}} feature:
* SPIFFE client authentication and RFC 8693 token exchange: the downstream
token carries the user ({{sub}}), the API audience and {{azp}} = the MCP
server; exchanged tokens are cached per user;
* step-up: a route requiring {{acr}} 2 answers {{401 WWW-Authenticate: Bearer
error="insufficient_user_authentication", acr_values="2"}};
* a JWT-SVID used as bearer token, validated by camel-oauth with the JWKS of
the SPIRE OIDC Discovery Provider;
* a JWT bearer exchange against a stand-in implementing the Anthropic workload
identity federation protocol, with the token renewed before expiry by
camel-openai;
* refused as expected: another workload, a JWT-SVID for another audience, a
client without the token exchange permission.
h2. Follow-ups, not in this scope
* Per-tool scopes and step-up at the MCP HTTP layer: a challenge can only reach
the client as tool text today.
* MCP clients of camel-openai and camel-langchain4j-agent acting for the end
user: the MCP client is created once per endpoint.
* Delegation chain ({{act}} claim): depends on the authorization server;
Keycloak 26.8 sets {{azp}} but no {{act}}.
_Claude Code on behalf of Federico Mariani_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)