Expand description
The consent seam.
plan/oauth.md’s hard part: OAuth’s authorize step assumes a human at a
browser, and an agent has none. What stands in for the person is the
agent’s own daemon: POST /oauth/par mints a decision record and a
one-time ConsentReference for it, the daemon reads the decision
through bot.did.listPendingAuthorizations and answers it with
bot.did.approveAuthorization, carrying that reference under
Credential::AccountSelf. The DID doing the approving is therefore the one
the presented agent token authenticates as, never a value in the body.
What this module builds is everything behind that route:
ConsentReference minting, ConsentStore, and confirm — the
function the route reaches, doing two checks:
- the reference is live and unused, and
- the account named in the request is the authenticated agent.
Policy is not one of them. The sign-in was judged once, at PAR
(crate::oauth::par), and the answer is in the record: a record whose
verdict is a denial carries no reference, so there is nothing here to
confirm. Evaluating again at this point could only contradict a record
that already told the agent allow.
§The invariant
Approval happens because the named agent confirmed, never because
there was nobody to say no. confirm takes the authenticated DID as
an explicit argument rather than trusting anything in the request body,
so a caller cannot self-attest its own identity.
Structs§
- Consent
Reference - A one-time reference minted when
authorizeis ready for confirmation. - Memory
Consent Store - The in-process consent store.
- Pending
Consent - What a pending consent decision is about.
Enums§
- Consent
Error - Why
confirmrefused.
Constants§
- CONSENT_
TTL - How long a minted consent reference stays live before it must be reissued.
- REFERENCE_
BYTES 🔒 - Random bytes a reference is drawn from.
Traits§
- Consent
Store - Where pending consent decisions live between
authorizeminting a reference and a stamped call confirming it.
Functions§
- begin
- Mints a pending consent, for
authorizeto hand back as the reference the agent’s confirming tool call must carry. - confirm
- This is the seam. A future
PreToolUse-stamped tool call reaches this function (through whatever HTTP or in-process boundary the harness that drives it uses — not decided here) withreferencefrom the tool call’s arguments andstamped_didfrom the rewrite, not from the caller.