Repository navigation
feat(ciba): expiry audit event, decision metrics, login-detour e2e - #958
Merged
Merged
Conversation
…mode Adds backchannel_token_delivery_mode to the admin client API (GraphQL _create_client/_update_client/Client, gRPC/REST CreateClient/UpdateClient/ Client). "poll" registers the client for CIBA (OpenID CIBA Core 1.0 §4), "" removes it, omitted leaves it unchanged; any other value is refused. Stored as the CIBA grant URN in the existing grant_types column (written by every backend's full-record UpdateClient), so no schema change. Other grant types on the row are preserved. Dynamic registration still accepts only authorization_code/refresh_token, so it cannot enable CIBA. Nothing reads the flag yet; the CIBA endpoints follow in the next PR and are additionally gated server-wide by --enable-ciba.
…(beta) Implements phase 4a of the CIBA design (authorizerdev/docs#112), off by default behind --enable-ciba and a per-client opt-in. - POST /oauth/bc-authorize (CIBA Core 1.0 §7): service accounts only; login_hint (user id) or id_token_hint (signature verified, aud must contain the client, accepted up to 30 days expired per §14); required binding_message (≤64 chars, no Cc/Cf); RFC 9396 authorization_details limited to --ciba-authorization-details-types; exactly one external resource (never Authorizer itself); no authorizer: scopes. Unknown, revoked, out-of-org, capped and blocked users get the same answer and the same storage round trips (timing probe test). - GET/POST /oauth/bc-approve: session cookie only (ValidateBrowserSession, never bearer); step-up via --ciba-step-up-max-age and no magic-link sessions, reusing forceReauth's revocation (now revokeBrowserSession) and the SAML-style /app login detour (isCibaApproveURL in the login UI); single-use per-render form token bound to the session plus an Origin check; approve / deny (1h block) / deny-and-block (24h). - CIBA grant at /oauth/token: authorization_pending, slow_down (+5s), expired_token, access_denied, single redemption. Issues a 5-minute delegated token (act.sub = agent, aud = resource, authorization_details and ciba{req,msg,approved_at} claims, no sid so it cannot authenticate at Authorizer) and a scope-redacted ID token (amr from the approving sign-in). Token response carries scope and authorization_details (RFC 9396 §7). - Channels: ciba_approval email template and user.approval_requested webhook, sent in the background. - Discovery fields, audit events (ciba.*), metrics, startup validation (TLS --url per §7) and warnings (no SMTP, magic-link-only sign-in, own origin missing from --allowed-origins). - Client assertion aud: issuer/token/backchannel URLs accepted at the backchannel endpoint when expected_aud is one of them (CIBA §7.1). Tests: integration (poll flow, approval page auth/CSRF/step-up, deny and block, caps, org boundary, unknown users, validation, id_token_hint, timing probe), unit, release smoke against the real binary.
…air caps, atomic stores From the implementation security review: - High: token exchange accepted a CIBA access token as subject_token and minted a token for any resource without authorization_details or the ciba claim, with a fresh lifetime. Refuse subject tokens carrying a ciba or authorization_details claim (regression test fails without it). - Medium: the cross-client per-user total counted undeliverable requests, so one agent (blocked, out of org, over its own cap) could silence all others. Count only deliverable requests; the other path reads the counter so both paths make one storage round trip. - Medium: on DynamoDB and Cassandra/ScyllaDB the database memory store's SetCacheNX is an upsert, so single redemption and first decision were not atomic. --enable-ciba now requires --redis-url there. - Low: resource check compares hosts only (scheme, port, trailing dot ignored); authorization_details labelled as the agent's unverified description; Zl/Zp refused; TTLs floored at 1s; user.* variables passed to the ciba_approval email; Root.tsx doc comment back in place.
TestCIBACaps took the email count right after three requests, while the third email could still be sending in the background, so a late email was counted as a fourth (flaky in CI). Wait for all three first.
backchannel_token_delivery_mode="poll" is refused for a client that is not a service account (the backchannel endpoint rejects every other kind) and for one whose allowed_scopes lack openid (every CIBA request must include it), including when an update removes openid from a CIBA client. Found in review.
…into feat/ciba-poll
… blocks, MFA detour - Enumeration: undeliverable requests now increment a shadow counter instead of reading the total, so every path makes the same storage calls. On the database memory store (the default without Redis) IncrementCache is several statements, so known users were measurably slower. New TestCIBAUserCanBeAskedStorageParity records the calls for deliverable, unknown, revoked, blocked, capped and out-of-org users and requires them identical; it fails on the previous code. - Resource check: same host AND port is Authorizer (default ports 80/443 count as one, trailing dot and case ignored). Host-only comparison refused every API on localhost, so local development could not work. - Deny-and-block uses its own 24h key, so a later plain deny cannot shorten it; a failed block write is logged at warn. - Sign-in detour carries mfa_required/mfa_methods/mfa_gate to /app, so a social or SSO login stopped for MFA continues instead of looping. - --ciba-poll-interval minimum is 2 (1 made exact one-second polling get slow_down on the in-memory store). - Tests: CIBA flow and approve/deny race on the database memory store; approve after expiry; plain deny blocks and cannot shorten a 24h block; revoked user indistinguishable when polled; bearer test uses the request's own user's token; background sends are drained instead of slept on before 'nothing was sent' assertions.
…trics
- ciba.expired is written the first time the agent's poll finds an
undecided request expired (the memory store cannot be scanned on every
backend, so there is no sweep). Every expired poll makes the same store
call; requests that could never reach a user are not recorded.
- authorizer_ciba_outcomes_total{client_id,outcome} for a per-agent deny
rate, and authorizer_ciba_time_to_decision_seconds{outcome}.
- The request record carries created_at for the histogram.
A dedicated authorizer-ciba instance behind an nginx TLS front (CIBA refuses an http --url off loopback, with no test bypass) using the stack's e2e CA. The spec opens the emailed approval link with no session, signs in through /app, lands back on /oauth/bc-approve, approves, and the agent's poll redeems a delegated token once; a second link with the session live opens the approval page directly, and a deny reaches the agent.
lakhansamani
added a commit
that referenced
this pull request
Nov 30, 2026
…ters The design (§10) puts the new events in the audit filters; they were missing, including ciba.expired from #958. CIBA decisions are recorded against the agent's service account, so that resource type is filterable too.
lakhansamani
added a commit
that referenced
this pull request
Dec 1, 2026
…ate (#955) * feat(clients): per-client CIBA opt-in via backchannel_token_delivery_mode Adds backchannel_token_delivery_mode to the admin client API (GraphQL _create_client/_update_client/Client, gRPC/REST CreateClient/UpdateClient/ Client). "poll" registers the client for CIBA (OpenID CIBA Core 1.0 §4), "" removes it, omitted leaves it unchanged; any other value is refused. Stored as the CIBA grant URN in the existing grant_types column (written by every backend's full-record UpdateClient), so no schema change. Other grant types on the row are preserved. Dynamic registration still accepts only authorization_code/refresh_token, so it cannot enable CIBA. Nothing reads the flag yet; the CIBA endpoints follow in the next PR and are additionally gated server-wide by --enable-ciba. * feat(ciba): OpenID CIBA poll mode — human approval for agent actions (beta) Implements phase 4a of the CIBA design (authorizerdev/docs#112), off by default behind --enable-ciba and a per-client opt-in. - POST /oauth/bc-authorize (CIBA Core 1.0 §7): service accounts only; login_hint (user id) or id_token_hint (signature verified, aud must contain the client, accepted up to 30 days expired per §14); required binding_message (≤64 chars, no Cc/Cf); RFC 9396 authorization_details limited to --ciba-authorization-details-types; exactly one external resource (never Authorizer itself); no authorizer: scopes. Unknown, revoked, out-of-org, capped and blocked users get the same answer and the same storage round trips (timing probe test). - GET/POST /oauth/bc-approve: session cookie only (ValidateBrowserSession, never bearer); step-up via --ciba-step-up-max-age and no magic-link sessions, reusing forceReauth's revocation (now revokeBrowserSession) and the SAML-style /app login detour (isCibaApproveURL in the login UI); single-use per-render form token bound to the session plus an Origin check; approve / deny (1h block) / deny-and-block (24h). - CIBA grant at /oauth/token: authorization_pending, slow_down (+5s), expired_token, access_denied, single redemption. Issues a 5-minute delegated token (act.sub = agent, aud = resource, authorization_details and ciba{req,msg,approved_at} claims, no sid so it cannot authenticate at Authorizer) and a scope-redacted ID token (amr from the approving sign-in). Token response carries scope and authorization_details (RFC 9396 §7). - Channels: ciba_approval email template and user.approval_requested webhook, sent in the background. - Discovery fields, audit events (ciba.*), metrics, startup validation (TLS --url per §7) and warnings (no SMTP, magic-link-only sign-in, own origin missing from --allowed-origins). - Client assertion aud: issuer/token/backchannel URLs accepted at the backchannel endpoint when expected_aud is one of them (CIBA §7.1). Tests: integration (poll flow, approval page auth/CSRF/step-up, deny and block, caps, org boundary, unknown users, validation, id_token_hint, timing probe), unit, release smoke against the real binary. * fix(ciba): security review — refuse exchanging action-bound tokens, fair caps, atomic stores From the implementation security review: - High: token exchange accepted a CIBA access token as subject_token and minted a token for any resource without authorization_details or the ciba claim, with a fresh lifetime. Refuse subject tokens carrying a ciba or authorization_details claim (regression test fails without it). - Medium: the cross-client per-user total counted undeliverable requests, so one agent (blocked, out of org, over its own cap) could silence all others. Count only deliverable requests; the other path reads the counter so both paths make one storage round trip. - Medium: on DynamoDB and Cassandra/ScyllaDB the database memory store's SetCacheNX is an upsert, so single redemption and first decision were not atomic. --enable-ciba now requires --redis-url there. - Low: resource check compares hosts only (scheme, port, trailing dot ignored); authorization_details labelled as the agent's unverified description; Zl/Zp refused; TTLs floored at 1s; user.* variables passed to the ciba_approval email; Root.tsx doc comment back in place. * test(ciba): wait for background emails before counting in the caps test TestCIBACaps took the email count right after three requests, while the third email could still be sending in the background, so a late email was counted as a fourth (flaky in CI). Wait for all three first. * feat(dashboard): CIBA client toggle, approval webhook and email template - Clients: "Human approval (CIBA)" switch on create/edit, sent as backchannel_token_delivery_mode ("poll" / ""), and a CIBA badge in the list. - Webhooks: user.approval_requested event. - Email templates: ciba_approval event, with its variables (agent_name, binding_message, approval_url, expires_in_minutes, resource) shown only for that event, which has no verification_url. * fix(clients): accept CIBA only for service accounts with openid backchannel_token_delivery_mode="poll" is refused for a client that is not a service account (the backchannel endpoint rejects every other kind) and for one whose allowed_scopes lack openid (every CIBA request must include it), including when an update removes openid from a CIBA client. Found in review. * fix(ciba): second review — storage parity, port-aware resource check, blocks, MFA detour - Enumeration: undeliverable requests now increment a shadow counter instead of reading the total, so every path makes the same storage calls. On the database memory store (the default without Redis) IncrementCache is several statements, so known users were measurably slower. New TestCIBAUserCanBeAskedStorageParity records the calls for deliverable, unknown, revoked, blocked, capped and out-of-org users and requires them identical; it fails on the previous code. - Resource check: same host AND port is Authorizer (default ports 80/443 count as one, trailing dot and case ignored). Host-only comparison refused every API on localhost, so local development could not work. - Deny-and-block uses its own 24h key, so a later plain deny cannot shorten it; a failed block write is logged at warn. - Sign-in detour carries mfa_required/mfa_methods/mfa_gate to /app, so a social or SSO login stopped for MFA continues instead of looping. - --ciba-poll-interval minimum is 2 (1 made exact one-second polling get slow_down on the in-memory store). - Tests: CIBA flow and approve/deny race on the database memory store; approve after expiry; plain deny blocks and cannot shorten a 24h block; revoked user indistinguishable when polled; bearer test uses the request's own user's token; background sends are drained instead of slept on before 'nothing was sent' assertions. * feat(dashboard): list the scopes and details CIBA email variables * fix(dashboard): consistent value format for the scopes/details variables * fix(ciba): no Redis requirement on DynamoDB or Cassandra/ScyllaDB #957 makes the database memory store's single-use claim atomic on every backend, so CIBA's first-decision-wins and single redemption hold without Redis. Merge after #957. * feat(dashboard): CIBA events and service_account in the audit log filters The design (§10) puts the new events in the audit filters; they were missing, including ciba.expired from #958. CIBA decisions are recorded against the agent's service account, so that resource type is filterable too.
# Conflicts: # internal/constants/ciba.go # internal/http_handlers/ciba.go # internal/http_handlers/ciba_approve.go # internal/http_handlers/ciba_authorize.go # internal/http_handlers/ciba_token.go # internal/integration_tests/ciba_test.go
# Conflicts: # go.mod
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-ups deferred from CIBA (#954, design §10 and §12). Stacked on #954: merge that first, and GitHub moves this to
main.ciba.expiredaudit eventWritten the first time the agent's poll finds an undecided request expired (inside the grace period). The memory store can't be scanned on every backend, so there is no sweep: a request the agent never polls again leaves only
ciba.requested.SetCacheNX, so repeated polls add nothing.Metrics
authorizer_ciba_outcomes_total{client_id, outcome}, whereoutcomeis approved, denied, blocked or expired. It gives a deny rate per agent, which you can alert on:sum by (client_id) (rate(authorizer_ciba_outcomes_total{outcome=~"denied|blocked"}[1h])) / sum by (client_id) (rate(authorizer_ciba_outcomes_total[1h])).client_idcardinality is bounded, because only service accounts an admin registered can use CIBA. Requests that could never reach a user are not counted.authorizer_ciba_time_to_decision_seconds{outcome}uses buckets from 5 s to 600 s. The request record now carriescreated_atfor it.authorizer_security_events_total{event="ciba_channel_failed"}.e2e-playground: approval through the real login UI
authorizer-cibainstance runs behind an nginx TLS front that uses the stack's e2e CA. CIBA refuses an http--urloff loopback, and following the suite's own rule there is no test bypass. The e2e leaf certificate gains the SANauthorizer-ciba.tests/ciba.spec.tsruns in the newcibaproject:/appand lands back on/oauth/bc-approve.sub= user,act.sub= agent,aud= resource) exactly once.access_denied.Verification
TestCIBAExpiryIsRecordedOnceandTestCIBADecisionMetricspass, and both fail with the change removed.TestCIBA*tests pass, and so does the fullmake test(SQLite, 48 packages);go vetandmake lintare clean.ciba.spec.tspasses against a freshly built image. In a scratch worktree withisCibaApproveURLdisabled it fails, timing out after "Log In", so it guards the detour.The MCP URL-elicitation example is in authorizerdev/examples#26.