Repository navigation
Process the ID-JAG authorization_details claim - #7290
Conversation
Redemption will process the authorization_details claim an ID-JAG carries, and the issued token must carry the entries exactly as signed. The claims decoded through map[string]any lose integer precision above 2^53, so verifySignature now also decodes the verified payload into a map of raw members and keeps the authorization_details bytes in ValidatedClaims.AuthorizationDetails (nil when absent). A map, not a struct field, so a member in another letter case does not match. No behaviour changes: nothing reads the new field yet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ID-JAG draft section 4.4.1 requires the redeeming server to process the authorization_details claim the ID-JAG's issuer signed, and a gateway token narrowed to one MCP call depends on it. Until now redemption refused every assertion that carried the claim. The ID-JAG handler now processes the claim after subject resolution and before the ID-JAG is consumed: a claim that is not a non-empty array of objects is invalid_assertion; a type not registered for the JWT-bearer grant (or no registry) is unknown_type; a shape problem is malformed_entry; the registered hooks decide; and every granted entry must equal a distinct signed entry as a JSON value, so a hook can drop whole entries but never change or add one (server_error). The granted entries go into the access token and the token response from the same raw bytes, so large integers keep every digit. Narrowing inside an entry is left to "Narrow authorization_details on token exchange and refresh" (#6912). Both redemption forms refuse the authorization_details parameter with parameter_not_allowed, and the plain RFC 7523 grant keeps refusing the claim. The hook sees the authenticated client, the granted resource, the ID-JAG's sub, and a new Subject.ResolvedUser for a resolve issuer. Registry.Parse reports ErrUnknownType so the two refusals differ. A registry is now reachable with the JWT-bearer grant alone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #7290 +/- ##
==========================================
+ Coverage 81.92% 81.97% +0.04%
==========================================
Files 922 923 +1
Lines 93314 93556 +242
==========================================
+ Hits 76451 76691 +240
- Misses 16858 16860 +2
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Resolve the conflicts with the per-client lifespan and the MCP tool-call type. The ID-JAG factory now applies both the client lifespans and the authorization details registry, so drop the registry refusal and its test case. The arch doc keeps both new paragraphs and states that an ID-JAG's signed mcp_tool_call entry goes through the type's hook on redemption. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jhrozek
left a comment
There was a problem hiding this comment.
A few things that aren't anchored to a changed line:
-
Rebase: "Add a per-client access token lifespan for ID-JAG redemption" (#7284) and "Add the MCP tool-call details type" (#7283) both landed since this branch was cut, and it no longer merges cleanly (docs/arch/17, factory.go, id_jag_handler.go, redeemer.go). Details inline on IDJAGIssuanceFactory.
-
Release order: with "Add the MCP tool-call details type" (#7283) on main, toolcalldetails registers for both token exchange and jwt-bearer, so an embedder that registers it gets single-call tokens out of redemption as soon as this merges. The vMCP doesn't read authorization_details until "vMCP: accept an access token for the one call its authorization_details names, once" (#7062), so until then such a token is good for any call. Could the "Release order" section say that too: this PR, then #7062, then AS-1 signing the claim? Right now it only orders AS-1 vs AS-2.
-
docs/arch/17-token-exchange-delegation.md:1554 (not in the diff): the check order for a resolve issuer is missing the two new steps. Something like: "client authentication and grant, the
authorization_detailsparameter, assertion validation,jti, client binding, policy (resource), client audience, actor issuer, gate, resolution, actor policy, theauthorization_detailsclaim, consume, lifetime." -
docs/arch/17-token-exchange-delegation.md:1682 (not in the diff): the retry paragraph after the refusal table covers invalid_grant and access_denied but not the new code. Worth one sentence: an invalid_authorization_details refusal depends only on the signed details, so a re-issued ID-JAG with the same authorization_details gets the same answer; parameter_not_allowed goes away by dropping the parameter.
Build the granted authorization_details from the signed entries a hook keeps (Pending.GrantSubset), so the issued token carries the issuer's bytes. A type whose hook keeps none of its entries is dropped; the redemption is refused with empty_grant only when nothing is left. A hook that returns a changed or added entry is still a server_error. ErrNoEntries is removed and Pending.Grant is unchanged. Keep the authorization_details claim raw when a session is decoded from storage, refuse a repeated parameter with invalid_request, bound the ID-JAG refusal WARN lines per (client or issuer, reason), require ID-JAG redemption rather than any JWT-bearer issuer for registry reachability, and record the resolved user on the redemption. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep the fields every grant fills on authorizationdetails.Request and move the grant-specific ones into parts a hook checks for nil: Exchange (actor, actor-token presence, requested token type, requested scopes) on token exchange and Redemption (resolved user) on ID-JAG redemption. ResolvedUser moves out of Subject. The MCP call hook now grants only on ID-JAG redemption or on a token exchange for an ID-JAG, and refuses a request with neither part. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jhrozek
left a comment
There was a problem hiding this comment.
Thanks, all the earlier comments are addressed. GrantSubset handing back the signed bytes and empty_grant being decided once after merging are both nicer than what I asked for.
Summary
Review commit by commit. The PR is above the usual size, so it is split into two commits: "Keep the raw authorization_details bytes" (about 60 non-test lines, no behaviour change: the validator keeps the claim's raw bytes so integer precision survives) and "Process the ID-JAG authorization_details claim" (the processing, refusals, wiring and docs). After those: a merge of main (the per-client lifespan and the tool-call type) and three review commits, "Address review of the ID-JAG details processing", "Update the authorization details docs for ID-JAG redemption" and "Split the authorization details request by grant".
Builds on "Refuse tokens that carry authorization_details" (#7282), now in main: this PR narrows that refusal to the plain RFC 7523 grant and processes the claim on the ID-JAG grant instead.
A client that redeems an ID-JAG at this authorization server gets an access token good for any call to the resource. To narrow a gateway token to one MCP call, the call has to travel in the ID-JAG's signed
authorization_detailsclaim, and the redeeming server has to carry it into the token. ID-JAG draft §4.4.1 requires the redeeming server to process that claim. Today redemption refuses every assertion that carries it. This PR makes the ID-JAG handler process it, as specified in "Authorization server: narrow a JWT-bearer access token to one MCP call with authorization_details" (#7061).verifySignaturealso decodes the verified payload into a map of raw members and keeps theauthorization_detailsbytes inValidatedClaims.AuthorizationDetails(nil when absent), so integers above 2^53 keep every digit. A map, not a struct, so another letter case does not match. This is its own behaviour-preserving first commit.grantSignedDetailsinredemption_details.go):null,[], a string, an object, or an array with a non-object isinvalid_grant/invalid_assertion;invalid_authorization_details/unknown_type, logged at WARN with the ID-JAG issuer and the entry types (never the entries);malformed_entry;authorizationdetails.Errorreasons pass through;1and1.0differ), and the grant is built from the signed bytes (Pending.GrantSubset), so the token carries exactly what the issuer signed. A hook that changes or adds an entry is a hook bug:server_error, a log line, and no token;empty_grantonly when no entry is left after merging all types, because a redeemed token without details would be unrestricted.authorization_detailsclaim and the token response'sauthorization_detailsmember, from the same bytes.authorization_detailsparameter withinvalid_authorization_details/parameter_not_allowed, before the assertion is consumed. A single empty value counts as absent; a repeated parameter isinvalid_request("The authorization_details parameter must not be repeated."), as on token exchange.invalid_grant/invalid_assertion; the AS-3 refusal now runs on the plain handler only.authorizationdetails.Requestis split by grant: a common core (Entries,GrantType,ClientID,GrantedAudience,Subject), plusExchange *ExchangeContext(Actor,ActorTokenPresent,RequestedTokenType,RequestedScopes), set only on token exchange, andRedemption *RedemptionContext(ResolvedUser), set only on ID-JAG redemption. A hook checks the part for nil before reading it. On redemptionClientIDis the authenticated client,GrantedAudienceis[resource],Subject.Subjectis the ID-JAG'ssubandExternalis true;Redemption.ResolvedUseris set only when the redemption resolved the subject (subject_mode: resolve).Subject.Claimsno longer holds the lossy decoded copy ofauthorization_details; hooks readRequest.Entries.Registry.ParsereturnsErrUnknownType(which wrapsErrInvalid) when every entry is well formed but a type is not registered, sounknown_typeandmalformed_entrycan differ. NewPending.GrantSubsetreturns the kept signed entries and the types that were dropped (Subset).IDJAGIssuanceFactorytakesoptions ...FactoryOptionand appliesWithAuthorizationDetailsRegistry, whichbuildJWTBearerFactoriesForConfigpasses.AuthorizationDetailsRegistryReachablenow takes the trusted issuers: a registry is reachable when token exchange is on or a trusted issuer accepts ID-JAG assertions (idJAGRedeemable, the same predicate the per-client lifespan check uses).Part of "Authorization server: narrow a JWT-bearer access token to one MCP call with authorization_details" (#7061). The per-client lifetime from that issue is "Add a per-client access token lifespan for ID-JAG redemption" (#7284), and the
mcp_tool_calltype is "Add the MCP tool-call details type" (#7283).Type of change
Test plan
task test)task lint-fix)Scoped runs while working:
go test -ldflags=-extldflags=-Wl,-w -race ./pkg/authserver/...andgolangci-lint run --allow-parallel-runners ./pkg/authserver/...(0 issues),codespellon the changed paths.New tests:
TestIDJAGRedemptionDetailsClaim: one row per error-table entry on the ID-JAG handler (shape refusals, presence in registered or extra claims only, no raw bytes, no registry, no registry with an untyped entry, exchange-only type, unregistered type, case-variant member, untyped entry, two entries, the same entry twice, hook refusal, hook failure, changed entry, added entry,1→1.0, hook granting nothing, dropping one of two entries, reordered members, the parameter in its forms). Every refusal asserts the consumer was never called; every success asserts the token claim and the response member are equal.TestJWTBearerRedemptionRefusesDetailsParameterandTestPlainRedemptionRefusesAuthorizationDetailsClaimfor the plain handler.TestPending_GrantSubset(kept, reordered, one dropped, a type dropped while another keeps one, every type dropped, changed / added / renumbered / rounded / foreign entries, trailing data, oversized entry),TestPending_GrantSubset_LoneSurrogate(the token carries the signed\ud800, not the hook's replacement character),TestEntryTypes,TestVerifySignature_AuthorizationDetailsRaw(absent, integer above 2^53,null, another letter case, a repeated member at the top level and inside an entry).TestIDJAGRedemptionDetailsHookRequest(namespaced issuer:ResolvedUserempty) andTestIDJAGRedemptionDetailsResolvedSubject(resolve issuer:ResolvedUserset andSubjectstill the ID-JAG'ssub; resolution failing: hook never called, nothing consumed).TestIDJAGRedemptionDetailsLogs(one WARN per refusal kind, never an entry's value) andTestJWTBearerDetailsParameterLogLevel(plain grant: WARN once per issuer, and a redemption without the parameter does not use up that WARN),TestIDJAGDetailsRefusalLogLevel(ID-JAG: WARN once per client or issuer and reason, DEBUG after).TestIntegration_IDJAGAuthorizationDetailsClaimredeems a test-signed ID-JAG carrying an entry with an integer above 2^53; the response member and the access token's claim equal the entry digit for digit.TestIntegration_AuthorizationDetailsIgnoredOnOtherGrantsbecameTestIntegration_AuthorizationDetailsParameterRefusedOnRedemption.TestIDJAGHandler_RedisBackedDetailscompares the stored claim byte for byte with the original, including9007199254740993;TestSession_UnmarshalJSONKeepsAuthorizationDetailsRawcovers the decoder.TestAuthorizationDetailsRegistryReachable,TestEmbeddedAuthServer_AuthorizationDetailsRegistryReachabilityandTestValidateAuthorizationDetailsRegistryForRunConfig.Changes
pkg/authserver/server/tokenexchange/validator.go,multi_issuer_validator.goauthorization_detailsbytes (first commit)pkg/authserver/server/tokenexchange/redemption_details.gopkg/authserver/server/tokenexchange/id_jag_handler.gopkg/authserver/server/tokenexchange/jwt_bearer_handler.gopkg/authserver/server/tokenexchange/redeemer.go,redemption_refusal.gopkg/authserver/server/tokenexchange/authdetails.go,refresh_token_handler.go,factory.godetailsSubjecttakes the resolved user and drops the claim fromClaims; option docspkg/authserver/authorizationdetails/ErrUnknownType,Requestsplit into a core plusExchangeContext/RedemptionContext,Pending.GrantSubsetandSubset, hook-contract docspkg/mcp/toolcalldetails/pkg/authserver/config.go,server_impl.go,runner/embeddedauthserver.gopkg/authserver/server/session/session.go,claimnames/authorization_detailsas raw JSONdocs/arch/17-token-exchange-delegation.md,docs/arch/README.md,docs/authz.mdDoes this introduce a user-facing change?
Yes. Before → after:
authorization_detailsparameter: the parameter was ignored → 400invalid_authorization_details,error_descriptionparameter_not_allowed. A single empty value is still treated as absent; a repeated parameter is 400invalid_request.authorization_detailsclaim: refused with 400invalid_grant/invalid_assertion(since "Refuse tokens that carry authorization_details" (Refuse tokens that carry authorization_details #7282)) → processed. The granted entries are in the access token'sauthorization_detailsclaim and in the token response'sauthorization_detailsmember. Refusals follow the table indocs/arch/17-token-exchange-delegation.md("On ID-JAG redemption"):invalid_assertionfor a malformed claim,unknown_type,malformed_entry, a hook's own reason,empty_grant, or 500server_errorfor a hook that grants an entry that was not signed.invalid_authorization_details,unknown_type, with a WARN line naming the ID-JAG issuer and the entry types. On a server that predates "Refuse tokens that carry authorization_details" (Refuse tokens that carry authorization_details #7282) such an ID-JAG was accepted and the token came out unrestricted. Release notes should call this out.invalid_grant/invalid_assertion(unchanged from Refuse tokens that carry authorization_details #7282).id_jagassertions was a startup error (ErrAuthorizationDetailsRegistryUnreachable) → accepted. With only plainjwt_bearerissuers it is still refused. The error text now reads "authorization details registry requires token exchange or ID-JAG redemption to be enabled";AuthorizationDetailsRegistryReachablechanges signature: in v0.69.0 it took onebool, now it also takes the trusted issuers;authorizationdetails.RequestmovesActor,ActorTokenPresent,RequestedTokenTypeandRequestedScopesinto the newExchange *ExchangeContext, set only on token exchange; a newRedemption *RedemptionContext(ResolvedUser) is set only on ID-JAG redemption. A hook reading those fields must read them through the part, after a nil check.Subject.Claimsno longer carriesauthorization_details;mcp_tool_callhook grants only on ID-JAG redemption or on a token exchange that requests an ID-JAG, and refuses a request with neither part (id_jag_required);Pending.GrantSubset,Subset,claimnames.AuthorizationDetailsKeyandsession.Session.UnmarshalJSON; a stored session holdsauthorization_detailsasjson.RawMessage;Request.Entries.Release order. This PR, then "vMCP: accept an access token for the one call its authorization_details names, once" (#7062), then AS-1 signing the claim into the ID-JAG. AS-2 processing (this PR) must ship in the same release as AS-1 signing, or an earlier one: an AS-2 without this PR refuses (or, before #7282, ignores) the claim. With "Add the MCP tool-call details type" (#7283) on main, an embedder that registers that type gets single-call tokens out of redemption as soon as this merges, but until the vMCP enforces the entry (#7062) such a token is still good for any call. The AS-1 signing PR says "Depends on" this one and stays in draft until it merges.
Special notes for reviewers
mcp_tool_calltype in Authorization server: narrow a JWT-bearer access token to one MCP call with authorization_details #7061, and stricter than the draft for other types. Per-type narrowing is "Narrow authorization_details on token exchange and refresh" (Narrow authorization_details on token exchange and refresh #6912). The same note is atgrantSignedDetails.[]asymmetry, on purpose. Token exchange accepts and echoes the parameter[]; redemption refuses the claim[](invalid_assertion), because a redeemed token without details is unrestricted.empty_grantis decided once. A type whose hook keeps none of its entries is a normal outcome; the redemption is refused only when nothing is left after merging. With the one registered call type that is exactly "every entry dropped".single_entry_requiredcomes from themcp_tool_callhook (Add the MCP tool-call details type #7283), not from the redemption code, so a future type may allow several entries. Two entries of two different registered types are each judged by their own hook.unknown_typefor any well-shaped claim, even an entry without atype, so the WARN line always tells the operator a registration is missing. That line names at most eight types, and logs any type that is not a short URI-like name as<invalid>, so no free-form claim text reaches the log.invalid_authorization_detailsas Authorization server: narrow a JWT-bearer access token to one MCP call with authorization_details #7061 specifies, not the draft'sinvalid_grant(§4.4.3), so the client gets an actionable reason. Comment atdetailsRefusal.JWTBearerIssuanceFactorytakes no options. The plain handler applies none (it refuses the claim and the parameter without a registry), and Add a per-client access token lifespan for ID-JAG redemption #7284 adds options only to the ID-JAG factory, so adding an unused variadic here would be dead surface. "Add a per-client access token lifespan for ID-JAG redemption" (Add a per-client access token lifespan for ID-JAG redemption #7284) also addsoptions ...FactoryOptiontoIDJAGIssuanceFactory; expect a small conflict there.Request.ExchangeorRequest.Redemptionfor nil instead of trusting that an empty field is empty for the right reason.session.Session.UnmarshalJSONkeepsauthorization_detailsasjson.RawMessagewhen a stored session is decoded, so memory and Redis hold the same bytes and big integers keep every digit.🤖 Generated with Claude Code