Skip to content

Mecatl's actor-token validator #2534

Closed

Description

@ChrisJBurns

Depends on: none open. No ToolHive dependency: registering this validator in hosted AS-1 is #2654, which waits on stacklok/toolhive#6899 and stacklok/toolhive#6898. It does not depend on #2677: its tests open sessions without AS-1.

Identity broker code only. It is built and tested against the identity broker; the harness's AS-1 calls it once #2535 adds ID-JAG issuance there. #2654 registers it in hosted AS-1.

Problem

Before issuing a grant, AS-1 must confirm the agent credential is genuine, that the agent's session belongs to the grant's user, and which ag_ identifier names the agent. AS-1 cannot do this itself (step (7), "How AS-1 runs check 6"): for client mecatl it calls a pluggable actor-token validator (stacklok/toolhive#6899), and Mecatl's validator runs in the identity broker. The broker's CredentialVerifier takes a broker session, which AS-1 does not have.

Design

Requirements

Per credentials-and-lifecycle.md step (7), "How AS-1 runs check 6", and step (4)'s SVID checks (inputs, check 8 at AS-1, outputs):

  • Checks: SVID checks 1–7, then check 8 at AS-1: the instance's present broker session is open, is owned by the given owner, and the credential was issued since the instance moved to that session, so a credential from before a close does not verify after the instance re-registers into the replacement session. "Registered to the call's broker session" is not AS-1's check; it stays at the broker's step (6), which Per-call grant and gateway token #2535 calls.

  • Owner: the form takes an identitybroker.Owner and compares it with the session's Owner, the owner registrations are checked against. (When AS-1 has converted a token for the session, its verified owner equals it.) Turning AS-1's sub_id (RFC 9493 JSON, iss_sub only) into an Owner is Register Mecatl's actor-token validator at hosted AS-1 #2654's, using the same rule as session open; an invalid Owner is denied.

  • Output on allow: the agent's ag_ identifier, its SPIFFE ID, and the credential's exp.

  • Refusals: only svid_expired for an expired credential and denied for everything else, including a malformed request, a closed broker session, and an agent whose session belongs to another user. session_closed is reported only by the broker, from its own records, never through this form.

  • Validator failure: any other error (internal, or an unavailable store once records persist) means the validator could not answer. That is a retryable infrastructure failure at AS-1, with nothing revoked (step (7)'s failure table); AS-1's mapping is Register Mecatl's actor-token validator at hosted AS-1 #2654's.

  • Access: two forms of the identity broker's credential verification on identitybroker.CredentialVerifier, apart from Core:

    • an owner-keyed form for AS-1's validator, as above;
    • the existing session-keyed form (VerifyCredential with a broker session ID), kept for the broker's step (6).

    Today VerifyCredentialRequest takes only a session ID (internal/identitybroker/service.go, boundary.go, agents.go) and returns the closing reason; add the owner-keyed form, and fix the comments that call the session check AS-1's (CredentialVerifier's doc in boundary.go, Broker.VerifyCredential's in agents.go, and the conformance suite's in conformance.go and credentials.go). AS-1's wiring takes CredentialVerifier only, never Core; here that is only where the method lives, since the wiring is Register Mecatl's actor-token validator at hosted AS-1 #2654's. This is a broker-internal call, not part of the interface Mecatl's session code uses.

Registering the validator at AS-1 (client mecatl only, token type pinned) and the questions for ToolHive are #2654's.

How it fits

Step 3 of the flow: AS-1 can issue a grant naming the user and a registered agent.

Done when

Against the identity broker, with no AS-1:

  • The owner-keyed form allows only a valid agent credential whose present session is open and owned by the given owner. It returns the agent's ag_ identifier, its SPIFFE ID, and the credential's exp.
  • An untrusted, malformed, wrong-audience, unregistered, or expired credential is refused with the broker's reasons (svid_expired, otherwise denied), and so are a credential from another user's session, one whose broker session is closed, and an invalid owner.
  • A credential issued before the instance's session closed is denied after the instance re-registers into the replacement session; the credential issued there passes.
  • An agent from another session of the same user passes the owner-keyed form; the session-keyed form refuses it.
  • Contract tests cover both verifier forms. When Per-agent registration and identities, switched on #2527 has landed, the owner-keyed cases run in both modes and return the instance's own ag_ identifier.

The real AS-1 calling this validator, with grants capped at the credential's expiry, is tested in #2654.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions