Skip to content

Commit bdc4812

Browse files
committed
fix(auth): the one-step door reads a sign-in identity on the user row as a claim
The judge reads the presence of a sign-in phone number on the stored user row, verified or not, as a claim (phone_number); a row it cannot read answers identity_unreadable. Every column of the vendor's user model with every plugin this plugin can mount is classified, and a test holds that classification to the composed instance. The user-keyed store pin also finds a column whose name ends in user_id. The rule text in the module doc, the ADR-0138 note and the changeset states the list and the classification. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nNrLRm8ssuwWcBVcw
1 parent 3c49959 commit bdc4812

4 files changed

Lines changed: 269 additions & 46 deletions

File tree

‎.changeset/34257-one-step-invitation-acceptance.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Metadata-protocol: none
1515

1616
- **The invitation mail carries a mailbox proof.** The accept link in the mail carries a single-use proof bound to the invitation, its address and its expiry; a resend retires it. The proof is never at rest in clear, the stored mail row never holds the proof, and the console's copy-link action answers the link without it. The invitation mail is sent inline, never through the durable mail queue, because the queue delivers from the stored row.
1717
- **One door redeems it.** `POST /api/v1/auth/organization/accept-invitation-one-step` takes the invitation id, the proof, a name and a password. In one request it creates the account (or sets the password of an account whose address is not verified, ending every session that account had with the reason a password reset records, in an order that matches the vendor's order), verifies the address, accepts the invitation and signs in. The password-age stamp and the forced-change clear that every password change writes are written too. On an account whose password it replaces, the password history is consulted before the proof is spent and extended after, as the reset door does. The proof is spent only by a request that passed every gate; one server process serializes concurrent redemptions of a proof, and across server processes single use is as strong as the store's consume. A bad proof gets one `INVALID_TOKEN` refusal that does not say which check failed, and the real proof stays usable. The door is rate-limited per client network address and per invitation, and runs the sign-up gates before anything is written: email sign-up switched off, SSO-only mode, password length, complexity and breach checks, a name for a new account, and who may sign up. A refused request leaves the proof usable.
18-
- **An address with an account signs in as today.** The door sets a password on an existing account only when it reads that the mailbox is the account's one claim: the address is not verified, the account's only sign-in account is its email and password one or it has none, it has no second factor, enabled or enrolled, no verified phone number and no standing grant (an API key, an OAuth client consent, an OAuth access or refresh token, an OAuth client, a device authorization, an SSO provider, a SCIM credential or a link to an identity provider's directory, revoked or expired ones included), its identity source is local, and the server allows a local password here (not SSO-only, email and password on). Every other account, including one in a state no rule names, answers `sign_in`, and the proof stays unspent. Every store the plugin mounts that is keyed by a user is classified as a claim the judge reads or as no claim, and a test holds that classification to the mounted list.
18+
- **An address with an account signs in as today.** The door sets a password on an existing account only when it reads all of these: the address is not verified; the account's only sign-in account is its email and password one, or it has none; it has no second factor, enabled or enrolled; its user row holds no phone number, verified or not; it holds no standing grant (an API key, an OAuth client consent, an OAuth access or refresh token, an OAuth client, a device authorization, an SSO provider, a SCIM credential or a link to an identity provider's directory, revoked or expired ones included); its identity source is local; and the server allows a local password here (not SSO-only, email and password on). Every other account answers `sign_in`, including one in a state no rule names and one whose reading fails, and the proof stays unspent. Every store this plugin mounts that is keyed by a user, and every column of the vendor's user model with every plugin this plugin can mount, is classified as a claim the judge reads or as no claim, and a test holds each classification to what is mounted. The classification covers what this plugin mounts and nothing another package mounts.
1919
- **`sys_device_code` gains an index on `user_id`** (`@objectstack/platform-objects`), so the door reads a user's device authorizations by an indexed lookup, as it reads every other standing grant.
2020
- **A cloud-managed environment refuses it.** With `OS_CLOUD_MANAGED=1` the door sets no local password: a request carrying a proof answers `409 RESOURCE_CONFLICT`, the cloud-managed refusal, before the proof is read. `CLOUD_MANAGED_REFUSAL_MESSAGES` gains the door's message. A process without the variable is unaffected.
2121
- **Without the proof, a session must hold the verified invited address.** Called with a session and no proof, the door accepts only when the session's address is the invited one and verified, and otherwise answers `verify_email`. A copied link still owes the verification mail.

‎docs/adr/0138-guest-model-anonymous-principal-doors-grants-and-organization.md‎

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -302,26 +302,27 @@ invitation-link sign-up still owes the verification mail.
302302

303303
**Amended 2026-11-16 — the one-step invitation acceptance and the OAuth client-name read, class-2-shaped doors.** Card
304304
[#34257](https://github.com/objectstack-ai/objectstack/issues/34257) admits one more door of class 2's shape, not a
305-
seventh class: `POST /api/v1/auth/organization/accept-invitation-one-step`. What admits the request: the mailbox
306-
proof the invitation mail carries, a capability token minted per send. The invitation id alone, which the copied link
307-
and the invitation row carry, admits nothing. What it runs as: after validation, the creation of the invited
308-
address's account (or the replacement of the password of an unverified account whose mailbox is its one claim,
309-
revoking its sessions), the address marked verified, the invitation accepted through the vendor's own accept route,
310-
and a session for that account. The proof is never at rest in clear, the stored mail row never holds it, and it is
311-
bound to the invitation, its address and its expiry; a resend retires the old one. It is spent only by a request that
312-
passed every gate, and one server process serializes concurrent redemptions of it; across processes, single use is
313-
as strong as the store's consume. Every proof that does not admit gets one refusal that does not say which check
314-
failed. The door sets a password on an existing account only when it reads that the mailbox is the account's one
315-
claim: the address is not verified, the account's only sign-in account is its email and password one or it has none,
316-
it has no second factor, enabled or enrolled, no verified phone number and no standing grant (an API key, an OAuth
317-
client consent, an OAuth access or refresh token, an OAuth client, a device authorization, an SSO provider, a SCIM
318-
credential or a link to an identity provider's directory, revoked or expired ones included), its identity source is
319-
local, and the server allows a local password here (not SSO-only, email and password on). Every other account,
320-
including one in a state no rule names, answers `sign_in`, and the proof stays unspent. Every store the plugin mounts
321-
that is keyed by a user is classified as a claim the judge reads or as no claim, and a test holds that classification
322-
to the mounted list. A cloud-managed environment
323-
sets no local password, so there the door refuses every request that carries a proof. It carries a rate limit per
324-
client network address and per invitation, as ADR-0121 D6 requires. Enforced by
305+
seventh class: `POST /api/v1/auth/organization/accept-invitation-one-step`. What admits the request: the mailbox proof
306+
the invitation mail carries, a capability token minted per send. The invitation id alone, which the copied link and
307+
the invitation row carry, admits nothing. What it runs as: after validation, the creation of the invited address's
308+
account (or the replacement of the password of an unverified account the rule below admits, revoking its sessions),
309+
the address marked verified, the invitation accepted through the vendor's own accept route, and a session for that
310+
account. The proof is never at rest in clear, the stored mail row never holds it, and it is bound to the invitation,
311+
its address and its expiry; a resend retires the old one. It is spent only by a request that passed every gate, and
312+
one server process serializes concurrent redemptions of it; across processes, single use is as strong as the store's
313+
consume. Every proof that does not admit gets one refusal that does not say which check failed. The door sets a
314+
password on an existing account only when it reads all of these: the address is not verified; the account's only
315+
sign-in account is its email and password one, or it has none; it has no second factor, enabled or enrolled; its user
316+
row holds no phone number, verified or not; it holds no standing grant (an API key, an OAuth client consent, an OAuth
317+
access or refresh token, an OAuth client, a device authorization, an SSO provider, a SCIM credential or a link to an
318+
identity provider's directory, revoked or expired ones included); its identity source is local; and the server allows
319+
a local password here (not SSO-only, email and password on). Every other account answers `sign_in`, including one in a
320+
state no rule names and one whose reading fails, and the proof stays unspent. Every store this plugin mounts that is
321+
keyed by a user, and every column of the vendor's user model with every plugin this plugin can mount, is classified as
322+
a claim the judge reads or as no claim, and a test holds each classification to what is mounted. The classification
323+
covers what this plugin mounts and nothing another package mounts. A cloud-managed environment sets no local password,
324+
so there the door refuses every request that carries a proof. It carries a rate limit per client network address and
325+
per invitation, as ADR-0121 D6 requires. Enforced by
325326
`packages/plugins/plugin-auth/src/invitation-mailbox-proof.ts#buildInvitationProofDoorPlugin`, ledgered in
326327
`packages/plugins/plugin-auth/src/auth-route-ledger.ts`. It is a better-auth endpoint, so it rides the `/auth`
327328
catch-all, which no route table lists door by door: the anonymous sweep's classification names it under class 2 as a

0 commit comments

Comments
 (0)