Repository navigation
fix(identitybroker): map ToolHive v0.66.0 actor reasons from AS-1 - #2823
Conversation
ToolHive v0.66.0 refuses an expired actor token at ID-JAG issuance with actor_token_expired, not svid_expired, adds approval_required, and adds the issuance reasons upstream_subject_missing, sub_id_missing, dpop_not_supported, and bound_elapsed. The broker treated all six as unknown, so an expired agent credential failed the call as a configuration fault instead of renewing the SVID and retrying once. Map actor_token_expired to svid_expired and approval_required to denied, report the other four by name, and make the identity harness answer an expired actor as ToolHive does. Co-authored-by: Mecatl <[email protected]>
ToolHive v0.66.0 shipped ID-JAG issuance and the actor validator, and its refusals differ from what the design assumed. AS-1 refuses an expired actor token with actor_token_expired, not svid_expired, adds approval_required, and adds upstream_subject_missing, sub_id_missing, dpop_not_supported, and bound_elapsed. A schedule grant presented for an ID-JAG is not_issuable, which the failure matrix called denied. Record the mapping the broker applies, and say what the broker does with an ID-JAG that returns after its session closed: AS-1 does not read the grant again after the validator, so the broker checks the session before using it. Note that replay-revoke (stacklok/toolhive#6973) and AS-2's reason codes (stacklok/toolhive#7030) are not built yet, and update the ToolHive work list rows that v0.62.0 and v0.66.0 completed. Co-authored-by: Mecatl <[email protected]>
|
Two things from the #2654 readiness check, both checked against ToolHive v0.66.0:
|
|
@jhrozek a design question this PR touches, which #2654 needs answered before it starts: what should ToolHive v0.66.0 refuses AS-1's own issuer as an
I'd go with A. Would you add it to step (7) and the Review of the rest of the PR, checked against ToolHive v0.66.0's source and against #2818:
With #2818: no conflicts, and the focused tests plus the cmd/mecak8s slice test pass on the two merged together. |
|
The 60s thing is ToolHive checking the validator's answer, not the SVID. If the validator refuses an expired SVID itself with actor_token_expired, which is what the validator contract asks for, the broker gets that reason however old the SVID is. server_error only happens if a validator accepts something that expired over a minute ago, and that's a validator bug. So I'd rather put a line in #2654 that our validator has to check expiry and refuse with actor_token_expired, than anything in #2538. Fine with A for act.iss. Since it'll never match the ID-JAG's iss, the embedded AS-2 needs the trust domain in its allowed actor issuers, so let's write that down next to it. I'll fix the refusal order and the act.iss row here. The "until #7030 lands" note on step 8 stays for now. I've got a follow-up on top of this PR that moves AS-2 to access_denied for valid ID-JAGs it won't take. |
ToolHive v0.66.0 refuses upstream_subject_missing and sub_id_missing while it decides the request, and dpop_not_supported right after that, both before it calls the actor validator. Only bound_elapsed comes after it. Move the two rows above check 6 in the step (7) failure table. The ToolHive work list marked the single-level act row done with act.iss set to AS-1's issuer, but v0.66.0 refuses a validator issuer equal to its own. Mark the row partly done until the act.iss value is settled. Co-authored-by: Mecatl <[email protected]>
|
Thanks Chris, all fair. On act.iss I went with your A, with one change. If act.iss is the trust domain, act.sub has to be a SPIFFE ID in it too. Otherwise we put a plain ag_ under a spiffe:// namespace it doesn't belong to, and ToolHive says it may start refusing that. So the SVID's sub itself becomes opaque, spiffe:///agent/ag_..., and the lineage stays in the registry only. act ends up as {iss: spiffe://agents.example.com, sub: spiffe://agents.example.com/agent/ag_7hq2x9}. The gateway still learns nothing about the lineage, and it's the shape the actor profile draft gives for a JWT-SVID actor token. One catch: trust domain names aren't unique (every interim install uses agents.mecatl.invalid), so the step 9 approval has to key on the ID-JAG iss plus act.iss, not act.iss alone. I'd rather do that in its own design PR. On main the code side is mostly re-keying the agent registry per instance and dropping the /inst/ suffix check in identity_broker.go. Ordering: pushed 6145870. One small correction to the first cut though: dpop_not_supported isn't first. ToolHive checks the DPoP header after the request is decided (client, grant, subject claims) and before it calls the validator. So the order is the checks up to 4, then the subject claim reasons, then DPoP, then the validator, then bound_elapsed. I moved the subject claim and DPoP rows above 6 in the step (7) table. Row 155 is back to "Partly" until act.iss is settled. In-flight: yes, authorize.go already does it (stillOpen, after the exchange and after redemption). I fixed the PR description, which said it was design only. Renewal window: agreed. It also means our production validator has to reject an expired SVID itself with actor_token_expired. Otherwise anything more than 60s past expiry comes back as a 500, which looks retryable but never succeeds. |
|
@jhrozek I've raised #2834, stacked on this PR, with what we agreed above:
The PR description lists the open tickets that need a small edit afterwards (#2527, #2552, #2553, #2555). Approval keying (ID-JAG |
Summary
actor_token_expired, notsvid_expired.approval_required.upstream_subject_missing,sub_id_missing,dpop_not_supportedandbound_elapsed.approval_requiredwould look like a broker bug.svid_expired, so our own tests agreed with the wrong string.knownReasonsgains the six reasons.idjagErrormapsactor_token_expiredtosvid_expiredandapproval_requiredtodenied.svid_expiredstill passes through.actor_token_expired, as ToolHive does.credentials-and-lifecycle.md,implementation.md):not_issuable, notdenied, for a schedule grant presented for an ID-JAG, matching step (7) and the code;The
stacklok/toolhivepin stays at v0.65.0; the bump belongs to #2654. This change only makes the broker ready for the reasons it will receive.Issue relationship
Relates to #2543
Relates to #2654
Type of change
Test plan
Baseline checks
task lint)task test)task test:race): run by CI (theTest (race)job), passinggo run ./cmd/mecademo): not affected; the change is in the broker's AS-1 refusal mappingtask docs), includingdocs:check --stricttask site:build): not applicabletask api:check): not applicabletask api:update+engine/CHANGELOG.md: not applicableFocused race tests pass:
go test -race ./internal/identitybroker/... ./internal/testutil/identityharness/... ./internal/adapter/server/....New table rows cover:
actor_token_expiredgives UNAUTHENTICATED withsvid_expired;svid_expiredgives the same;approval_requiredgives PERMISSION_DENIED withdenied;Changes
internal/identitybroker/serverrefusal.goknownReasons; the four issuance reasons inconfigurationFaultReasonsinternal/identitybroker/authorize.go,service.goidjagErrormapsactor_token_expiredandapproval_required; commentsinternal/testutil/identityharness/idjag.goactor_token_expired*_test.go(5 files)docs/drafts/agent-identity/credentials-and-lifecycle.mddocs/drafts/agent-identity/implementation.mdactrow stays partly doneUser-facing change
None today: Mecatl still pins ToolHive v0.65.0. After the bump, an expired agent credential is renewed and the call retried, instead of failing.
Special notes for reviewers
approval_requiredis reported asdenied, because Mecatl has no per-agent approval flow yet. If we want the broker to keep it distinct, that needs a new broker reason.bound_elapsed(the grant expired while the actor validator ran) is classified as a configuration fault, likegrant_invalid. It is closer to a race than a fault. The broker checks the stored expiry first, so it should not happen in practice.internal/identitybroker/authorize.go,stillOpen), so the doc now describes existing behaviour.upstream_subject_missingandsub_id_missingcome while AS-1 decides the request, anddpop_not_supportedright after (ToolHiveserver/handlers/token.go), all before the actor validator. Onlybound_elapsedcomes after it.act.issis still open. v0.66.0 refuses a validator issuer equal to its own, so the design'sact.iss= AS-1 cannot be configured. The work-list row is back to "Partly"; the new value and the step (7) text are for a separate design change.server/tokenexchange/actor_validator.go,id_jag_mint.go,refresh_token_handler.go. ToolHive's in-process flow test (in progress) pins the same strings over HTTP.