Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
7e0bdb8
fix(audit): record passkey deletion
Bccorb Nov 8, 2026
6b1205a
feat(webhooks): signed, retried webhooks built from the audit log
Bccorb Nov 8, 2026
1866332
fix(deps): use @seamless-auth/types 0.39.0
Bccorb Nov 8, 2026
d6efa56
feat(hooks): post_login and pre_token login hooks as signed callouts
Bccorb Nov 8, 2026
fdf7b16
feat(claims): static custom claims for roles and OpenID clients
Bccorb Nov 8, 2026
8730f93
feat(claims): share one token budget between permissions and custom c…
Bccorb Nov 8, 2026
108a784
docs(claims): record role-name order for custom claims
Bccorb Nov 8, 2026
ba740fc
feat(webhooks): catch a re-enabled endpoint up on what it missed
Bccorb Nov 8, 2026
794284e
chore: merge feat/signed-webhooks into feat/login-hooks
Bccorb Nov 8, 2026
5c1d6f5
chore: merge feat/login-hooks into feat/custom-claims
Bccorb Nov 8, 2026
bf9108b
fix(deps): use @seamless-auth/types 0.40.0
Bccorb Nov 8, 2026
7027943
fix(oidc): return empty customClaims and regenerate api types for typ…
Bccorb Nov 8, 2026
f523249
Merge remote-tracking branch 'origin/feat/signed-webhooks' into adopt…
Bccorb Nov 8, 2026
13c14ed
refactor(login-hooks): type refusal bodies with the shared error schemas
Bccorb Nov 8, 2026
4e295d1
Merge remote-tracking branch 'origin/feat/login-hooks' into adopt/cus…
Bccorb Nov 8, 2026
cfc145f
refactor(custom-claims): use the shared claim schemas directly
Bccorb Nov 8, 2026
e32e823
docs(adr): record that the shared claim schemas now generate
Bccorb Nov 8, 2026
fbdf04d
chore: merge main into feat/custom-claims after #583 was squashed
Bccorb Nov 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/custom-claims.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'seamless-auth-api': minor
---

Add static custom claims (ADR 0005, #417).

- Admin API under `/admin/custom-claims`: list every source with the reserved names, prefixes and budget, and read, replace or delete the set for an instance role, an organization role or an OpenID Provider client. Writes take step-up and are audited by claim name, never value.
- A set is refused when it uses a reserved name or prefix, a name outside `^[a-z][a-z0-9_]{0,63}$`, a value nested deeper than 3, or more than 1 KiB. The role or client must exist.
- First-party access tokens now carry the claims of the user's instance roles, then of their roles in the active organization (only while the membership exists), then the session's `pre_token` hook claims, a later source winning per name. Roles of one kind apply in name order. Recovery tokens carry none.
- OpenID Provider client sets are stored and served here, and applied by the provider in a later release.
- Permission claims and custom claims now share one 1 KiB token budget (`AUTHORIZATION_CLAIMS_BUDGET_BYTES`, replacing `PERMISSION_CLAIMS_BUDGET_BYTES`), so the server adapter's cookie holds the worst case. When both do not fit, permissions give way first and are replaced with `permissions_omitted: true`, as before. Only when the custom claims do not fit even beside that marker are they all dropped, and the mint writes `custom_claims_omitted`. Nothing is trimmed. This is a behavior change: a token with custom claims can now carry `permissions_omitted` at a smaller permission set than before.
- Retiring an instance role, deleting an organization role, or deleting an OpenID Provider application deletes its custom claims, so adding the name back does not restore them.
- New audit events `admin_custom_claims_updated`, `admin_custom_claims_deleted` and `custom_claims_omitted`.
16 changes: 16 additions & 0 deletions adapter-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@
{ "method": "GET", "path": "/admin/auth-events/export", "credential": "access" },
{ "method": "GET", "path": "/admin/auth-events/integrity", "credential": "access" },
{ "method": "GET", "path": "/admin/credential-count", "credential": "access" },
{ "method": "GET", "path": "/admin/custom-claims", "credential": "access" },
{
"method": "DELETE",
"path": "/admin/custom-claims/{sourceKind}/{sourceName}",
"credential": "access"
},
{
"method": "GET",
"path": "/admin/custom-claims/{sourceKind}/{sourceName}",
"credential": "access"
},
{
"method": "PUT",
"path": "/admin/custom-claims/{sourceKind}/{sourceName}",
"credential": "access"
},
{ "method": "GET", "path": "/admin/enrollment", "credential": "access" },
{ "method": "POST", "path": "/admin/enrollment/invites", "credential": "access" },
{ "method": "GET", "path": "/admin/login-hooks", "credential": "access" },
Expand Down
2 changes: 2 additions & 0 deletions docs/adr/0004-permissions-and-organization-roles.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ This differs from `requireRole`, deliberately. Roles keep their scoped matching.

The organization roles and the two permission arrays get 1 KiB, serialized, together. A server adapter keeps the whole access token inside a signed cookie, so it is base64 encoded twice under the browser's 4 KiB cookie limit, and a test builds that cookie at the budget. Over the budget all three are replaced with `"permissions_omitted": true`.

The 1 KiB is now shared with custom claims (ADR 0005, E6), and permissions are the first to give way when both do not fit.

Nothing is trimmed, because a partial list looks complete and denies silently. A guard that sees the marker reads `GET /users/me/permissions` with the caller's token and fails closed if it cannot. A plain 403 would turn an organization growing past a limit into an outage.

### P5. Organization roles are a catalogue
Expand Down
14 changes: 13 additions & 1 deletion docs/adr/0005-extensibility-callouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,14 @@ Sources, lowest precedence first: an instance role, an organization role (while

Reserved, refused when written and stripped (and audited) when a hook returns them: JWT registered claims, OpenID and OAuth protocol claims including `act` and `may_act`, Seamless's own claims, the OpenID standard identity claims (so no source can assert an email address the user never proved), and any name starting `seamless_` or `org_`. The list lives in `@seamless-auth/types/customClaim/reserved`, shared with the provider.

All custom claims together get 1 KiB serialized, on top of ADR 0004's permission budget. Unlike permissions they are never dropped: a static set over the budget is refused when written, and a hook over it has failed.
Each static set gets 1 KiB serialized, refused when written over it, and a hook over it has failed. In the token, custom claims share one 1 KiB budget with ADR 0004's permission claims (`permissions`, `org_roles`, `org_permissions`), serialized together, so the adapter cookie holds the worst case. Brandon chose this rule on 2026-11-07:

1. If the permission claims and the merged custom claims fit together, the token carries both.
2. Otherwise permissions give way first, since a guard has a live fallback for them and custom claims have none: the three are replaced with `"permissions_omitted": true` and the custom claims stay, if the custom claims and the marker fit.
3. Only when they do not fit even beside the marker are all custom claims dropped, and the mint writes `custom_claims_omitted`. The token then carries just the marker.
4. Nothing is ever trimmed partially. Recovery tokens carry neither.

Among roles of one kind, sets apply in role-name order, so the last name alphabetically wins a claim two of them set. It is deterministic and does not depend on the order roles were granted in, which an administrator cannot see. The console shows which role wins when two set the same claim. Brandon decided this on 2026-11-07.

### E7. SIEM streaming

Expand Down Expand Up @@ -124,6 +131,11 @@ They must be read back to sign, so they cannot be hashed. They are AES-256-GCM e
- When a mint finds the user has left the session's organization, the session's hook claims are cleared with the organization, since the hook decided them for it.
- `client` in the call is always null for now: no first-party sign-in knows which OpenID Provider client it is for. The provider can fill it in seamless-auth-oidc-provider#47.
- A test call sends a placeholder user and no request details, and is not recorded as an invocation.
- Custom claims (#417):
- Roles of one kind apply in role-name order (E6), rather than the order they are held in. Brandon confirmed this on 2026-11-07.
- Separate 1 KiB budgets for permissions and custom claims did not fit the server adapter's session cookie: 5670 bytes against 4096 at both, with only about 136 bytes of custom claims fitting beside a full permission set. Brandon chose the shared budget and the order in E6 on 2026-11-07. At the shared budget the worst-case cookie measures 3868 bytes.
- A set can only be written for a role or client that exists, and retiring the role or deleting the client deletes its set.
- `z.json()` in the shared claim schemas overflowed the OpenAPI generator. `@seamless-auth/types` 0.40.0 describes a claim value as a union bounded at the claim depth, so the route schemas use the shared ones directly.

## Consequences

Expand Down
5 changes: 3 additions & 2 deletions docs/api-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ All tokens are returned in the JSON body (the API never sets cookies). Present t

- **Access token** — a signed JWT (RS256). Claims include `sub` (user id), `sid` (session id),
`iss`, `typ: "access"`, `roles` and `permissions`. In an active organization it also carries
`org_id`, `org_roles` and `org_permissions`, which apply to that organization only. When the
permission claims would not fit, `permissions_omitted: true` replaces `permissions`, `org_roles`
`org_id`, `org_roles` and `org_permissions`, which apply to that organization only, and any
custom claims (ADR 0005). The permission claims and custom claims share one 1 KiB budget. When
they would not fit together, `permissions_omitted: true` replaces `permissions`, `org_roles`
and `org_permissions`, and absent then means "ask" rather than "none": read the live set from
`GET /users/me/permissions`. See [Permissions](./admin-operations.md#permissions).
Verify it against the JWKS at `GET /.well-known/jwks.json`.
Expand Down
Loading
Loading