Skip to content

Commit 3e35729

Browse files
committed
fix(auth): every user-keyed store the plugin mounts is classified for the one-step door
The closing rule's standing grants now cover every store the plugin mounts that grants an account standing access: API keys, OAuth client consents, OAuth access and refresh tokens, OAuth clients, device authorizations, second-factor enrolments, SSO providers, SCIM credentials and identity provider directory links. Each is one indexed read by user_id, limit 1, revoked rows included; a missing table holds no rows and any other failure answers sign_in as grant_unreadable. Every other user-keyed store is classified as no claim, and a test holds the classification to the list the plugin mounts. The session revocation and the password write match the vendor's order, pinned. sys_device_code gains an index on user_id. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nNrLRm8ssuwWcBVcw
1 parent 25e5034 commit 3e35729

5 files changed

Lines changed: 239 additions & 56 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
'@objectstack/spec': patch
33
'@objectstack/plugin-email': patch
44
'@objectstack/plugin-auth': patch
5+
'@objectstack/platform-objects': patch
56
'@object-ui/auth': patch
67
'@object-ui/app-shell': patch
78
'@object-ui/i18n': patch
@@ -13,8 +14,9 @@ Clause-②: yes (widening)
1314
Metadata-protocol: none
1415

1516
- **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.
16-
- **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), 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.
17-
- **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, no verified phone number, no API key and no OAuth client consent, 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.
17+
- **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.
19+
- **`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.
1820
- **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.
1921
- **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.
2022
- **`SendTemplateInput.deliverOnlyData`** (`@objectstack/spec`): render values delivered with the message and never written to the stored mail row, which gives no sign they were overlaid. Required template variables are checked against `data` alone. A send carrying them is delivered inline, never through the durable queue, so its sender gives up queued delivery where a queue is mounted. Only the server-side template send declares the key; `POST /email/send` and a script's `ctx.email.send` take a `SendEmailInput`, which has none.

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,13 @@ passed every gate, and one server process serializes concurrent redemptions of i
313313
as strong as the store's consume. Every proof that does not admit gets one refusal that does not say which check
314314
failed. The door sets a password on an existing account only when it reads that the mailbox is the account's one
315315
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, no verified phone number, no API key and no OAuth client consent, its identity source is
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
317319
local, and the server allows a local password here (not SSO-only, email and password on). Every other account,
318-
including one in a state no rule names, answers `sign_in`, and the proof stays unspent. A cloud-managed environment
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
319323
sets no local password, so there the door refuses every request that carries a proof. It carries a rate limit per
320324
client network address and per invitation, as ADR-0121 D6 requires. Enforced by
321325
`packages/plugins/plugin-auth/src/invitation-mailbox-proof.ts#buildInvitationProofDoorPlugin`, ledgered in

‎packages/platform-objects/src/identity/sys-device-code.object.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ export const SysDeviceCode = ObjectSchema.create({
161161
{ fields: ['device_code'], unique: 'global' },
162162
{ fields: ['user_code'], unique: 'global' },
163163
{ fields: ['status'], unique: false },
164+
// The one-step invitation door reads a user's device authorizations by
165+
// this column (`plugin-auth` `invitation-mailbox-proof.ts`).
166+
{ fields: ['user_id'], unique: false },
164167
],
165168

166169
enable: {

0 commit comments

Comments
 (0)