Skip to content

feat: manage webhooks, login hooks, custom claims and audit streaming - #343

Merged
Bccorb merged 4 commits into
mainfrom
feat/webhooks-hooks-claims-sinks
Nov 8, 2026
Merged

Bccorb merged 4 commits into
mainfrom
feat/webhooks-hooks-claims-sinks

Conversation

@Bccorb

@Bccorb Bccorb commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Console pages for the v0.23 extensibility routes (ADR 0005): Webhooks (#335), and Login hooks, Custom claims and Audit streaming (#336).

Depends on the unreleased API PRs fells-code/seamless-auth-api#580 (webhooks), #582 (audit sinks), #583 (login hooks) and #584 (custom claims). Until those ship, every page shows "Needs Seamless Auth API v0.23" on the 404 an older API answers, and does not retry it.


Changes

  • Webhooks (/webhooks): list, create (event types from WEBHOOK_EVENT_TYPES), edit, turn off and on with the disabledReason explained, delete, rotate secret (shown once, the old one signs for 24 hours), send a test event with its result. Delivery log with status, attempts, last status code and failure, the event body, an endpoint filter, a dead letter tab (status=dead), nextCursor paging and redeliver.
  • Login hooks (/login-hooks): one section per trigger with URL, timeout (100 to 5000 ms), failure mode (open versus closed explained), secret shown once on create and on rotation, test call, and the invocation log with an outcome filter. States that break-glass and recovery sessions never call a hook.
  • Custom claims (/custom-claims): a JSON set per instance role, organization role and OIDC client, with the reserved names, prefixes and budget taken from the list response, each set's size, the precedence order and the shared token budget rule. A reserved name, depth over 3 or a set over budget is refused before step-up; an API refusal shows the field (invalid_request details.issues). The page restates the order sources apply in (instance roles, organization roles, the OIDC client, then the pre_token hook), and when two roles of one kind set the same claim it shows "applied in role-name order; <role> wins", worked out from the list response with the API's own code-unit sort.
  • Audit streaming (/audit-streaming): OTLP and syslog sinks, header and TLS credentials as _AUDIT_SINK_SECRET env var names only (a value typed in their place is refused before any request), test record, and status with lag, last delivery and last failure, refreshed every 30 s. A turned-off sink still holds audit retention (the API never deletes an event a sink has not delivered): a turned-off sink that is behind shows "This sink still holds audit retention, so no event is lost. Delete it to release.", turning a sink off asks for confirmation stating the same, and the delete confirmation says deleting releases them.
  • Navigation: Webhooks, Login hooks and Audit streaming sit in an "Integrations" group in the sidebar; Custom claims sits beside Roles.
  • Every write calls ensureStepUp() first, as the Roles and Applications pages do; apiFetch still re-tries once on a lapsed step_up_required. Request bodies are validated with the @seamless-auth/types 0.40 schemas (CreateWebhookEndpointRequestSchema, UpdateWebhookEndpointRequestSchema, SetLoginHookRequestSchema, SetCustomClaimsRequestSchema, CreateAuditSinkRequestSchema, UpdateAuditSinkRequestSchema); responses are typed, not parsed, matching the existing pages.
  • Shared pieces: SigningSecretDialog, FormParts, src/lib/callouts.ts (failure reasons, test results, invalid_request issues), src/lib/customClaims.ts.
  • @seamless-auth/types to 0.40.0; the new audit event types get categories (Webhooks, Login Hooks, Custom Claims, Audit Streaming) and labels. session_created is a Session Tokens event, custom_claims_omitted ("Custom claims omitted from token") a Custom Claims one, and the two application link events stay under OpenID Provider. The local PENDING_EVENT_TYPES list is gone now that AUTH_EVENT_TYPES has the link events.
  • The misconfigured callout failure (a destination whose settings cannot be used, such as an unset _AUDIT_SINK_SECRET env var, so no call was made) has its own text in src/lib/callouts.ts.
  • README and AGENTS.md updated; two changesets (minor).

Type of Change

  • New feature

How to Test

  1. npm test, npm run test:e2e.
  2. Against an API built from seamless-auth-api#584 (with #582 merged in for sinks), open each page as a write admin, create something, and confirm the secret dialog, step-up prompt and refusals.

Checks (run locally at 9ca057e)

  • npm run typecheck: passes
  • npm run lint: passes
  • npm run format:check: "All matched files use Prettier code style!"
  • npm run coverage: 116 files, 942 tests passed; all files 82.6% statements, 81% branches, 79.48% functions, 84.82% lines (thresholds 62/52/60/64)
  • npm run build: built
  • npm run check:types-current: @seamless-auth/types "^0.40.0" is current (latest 0.40.0)
  • CI=1 npx playwright test (mocked /auth/* backend, fresh server): 248 passed, including 35 new specs across webhooks, login-hooks, custom-claims and audit-streaming

Not run

  • Nothing against a live API: the API PRs are open and unreleased, so every page was tested against mocked responses shaped from the 0.40 schemas and the route files on feat/custom-claims and feat/audit-sinks.

Notes

  • Test calls and redeliveries ask for step-up because the API routes them as writes.

Add four pages for the v0.23 extensibility routes (ADR 0005).

Webhooks: create, edit, turn off and on, and delete endpoints for the
published event types, with the reason the API turned one off. Rotate the
signing secret, shown once, with the old one signing for 24 hours beside
it. Send a test event and show the result. A delivery log per endpoint with
status, attempts, last status code, failure and event body, a dead letter
view, cursor paging, and redeliver.

Login hooks: one per trigger with URL, timeout, failure mode explained, a
secret shown once and rotation, a test call, and the invocation log. The
page says break-glass and recovery sessions never call a hook.

Custom claims: a JSON set per instance role, organization role and OpenID
Provider client, with the reserved names and budget from the list response,
checked before step-up, and the field the API refused.

Audit streaming: OTLP and syslog sinks whose credentials are env var names
only, a test record, and each sink's lag, last delivery and last failure.

Every write asks for step-up first, and an API older than v0.23 gets an
upgrade message. Bump @seamless-auth/types to 0.39 and categorize the new
audit events.

Closes #335
Closes #336
Put Webhooks, Login hooks and Audit streaming in an Integrations group in
the sidebar, with Custom claims kept beside Roles.

A turned-off audit sink still holds audit retention, since the API never
deletes an event a sink has not delivered. A turned-off sink that is behind
says so and that deleting it releases them; turning a sink off now asks for
confirmation stating the same, and the delete confirmation says it too.

The Custom claims page restates the order sources apply in, and when two
roles of one kind set the same claim it names the role that wins in
role-name order, worked out from the list response as the API sorts.
Rotating a secret closes the confirmation and opens the secret dialog in
the same step, so the shared helper's wait for no dialog raced it and lost
on CI. Wait for the confirmation itself to close instead.
@Bccorb
Bccorb marked this pull request as ready for review November 8, 2026 03:37
@Bccorb
Bccorb merged commit c467ece into main Nov 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant