fix(org-tokens): verified-session (human) mints skip the approval gate (core#2593) #2596
Reference in New Issue
Block a user
Delete Branch "fix/org-token-mint-verified-session"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Live regression (CTO-reported twice today): canvas Settings → Org API Keys → + New Key returns the raw #2579 anchor 400. The browser authenticates via a CP-verified WorkOS session (
AdminAuthsetscp_session_actorstrictly afterVerifiedCPSession), butapprovalAnchorForGatehas no session branch — #2579 assumed "the UI mints via the concierge", which is wrong: the canvas mints directly with the browser session.Design (core#2593): the gate puts a HUMAN between an AGENT and a privileged mint. When the minter IS the human, a pending-approval that same human would approve is a no-op round-trip → verified-session callers mint directly.
created_bynow records the per-session actor hash (better audit than the lossy"session"constant). Agent classes (admin-token / org-token) remain fully gated; their anchor-4xx contract is unchanged.Security: the human discriminator is
cp_session_actor(set ONLY post-verification) — never the raw Cookie header, which any bearer-authed agent can forge. The pre-existing forgeable Cookie checks inorgTokenActor/orgTokenActorClassare replaced with the verified key.Tests:
Create_VerifiedSession_SkipsGate(200,ExpectationsWereMetproves zero approval SQL ran, created_by = actor) +Create_ActorFromSessionrepurposed as the bypass-resistance pin (junk Cookie without verification → still 400). Full handlers package green;go build -tags=integrationclean.Remaining #2593 asks (NOT this PR): CP provisioner projecting
MOLECULE_PLATFORM_WORKSPACE_ID(agents-team hand-fixed), UI handling of 202 for the agent path.🤖 Generated with Claude Code
5-axis review on head
575789ca3c. Correctness: fixes the #2579 regression by allowing only CP-verified browser-session callers to mint directly, while admin-token/org-token callers still go through approvalAnchorForGate and gateDestructive. Robustness: empty-anchor handling remains fail-closed for non-session callers; created_by now records the stable session actor and the raw-cookie path still returns controlled 400. Security: the bypass is keyed on cp_session_actor, which AdminAuth sets only after VerifiedCPSession succeeds; raw Cookie classification was removed, and the bypass-resistance test pins that forged/junk cookies do not skip the gate. Agent classes remain gated. Performance: no new expensive calls on the handler path; verified-session work is already done by middleware. Readability: helper and comments make the human-vs-agent distinction explicit; tests cover the direct human mint path and forged-cookie non-bypass. Handlers-PG is green; broader CI was still settling at review time. Approved as agent-reviewer-cr2.