diff --git a/.changeset/cloud-managed-membership-changes-refused.md b/.changeset/cloud-managed-membership-changes-refused.md new file mode 100644 index 00000000000..951de16dd46 --- /dev/null +++ b/.changeset/cloud-managed-membership-changes-refused.md @@ -0,0 +1,19 @@ +--- +'@objectstack/plugin-auth': patch +'@objectstack/platform-objects': patch +'@objectstack/spec': patch +--- + +fix(auth)!: on a cloud-managed environment every organization door that writes or deletes a membership row refuses, add-member excepted; membership is managed by the hosting organisation + +Clause-②: no (narrowing) — narrowed: on a cloud-managed environment only (`OS_CLOUD_MANAGED=1`), six organization doors that write or delete a membership row now answer `409 RESOURCE_CONFLICT` to every request and write nothing, where they changed membership: `POST /organization/remove-member`, `POST /organization/update-member-role` (Make Owner calls it), `POST /organization/leave`, `POST /organization/accept-invitation`, `POST /organization/create` (it made the caller the new organization's owner) and `POST /organization/delete` (it ended every membership of the organization). Six refusal sentences are added (`CLOUD_MANAGED_REFUSAL_MESSAGES.removeMember`, `.updateMemberRole`, `.leaveOrganization`, `.acceptInvitation`, `.createOrganization`, `.deleteOrganization`). Their seven actions are hidden while `features.cloudManaged` is on, as the invite actions are (`sys_member.update_member_role`, `remove_member`, `transfer_ownership`; `sys_organization.leave_organization`, `create_organization`, `delete_organization`; `sys_invitation.accept_invitation`), and `PUBLIC_AUTH_FEATURES.cloudManaged.gatedInputs` books the seven paths. +Metadata-protocol: none +Skills-docs: none — no skill under `skills/**` teaches the organization membership doors or the cloud-managed mode; `content/docs/permissions/authentication.mdx` gains the rule in this change. + + + +**BREAKING** for a cloud-managed environment (`OS_CLOUD_MANAGED=1`, set only on hosted containers): membership and membership tiers are managed by the organisation that hosts the environment. Every organization door that writes or deletes a membership row refuses every request with `409 RESOURCE_CONFLICT` and writes nothing, as `POST /organization/invite-member` already did: Remove Member, Change Role and Make Owner, Leave Organization, Accept Invitation, Create Organization and Delete Organization. Their actions are hidden there. + +Who moves: an owner (or administrator) of a cloud-managed environment who changed membership from inside the environment, and a member who left, accepted an invitation, or created or deleted an organization there. Make the change in the hosting organisation instead. + +Unchanged: every self-hosted deployment (the variable unset), where every door answers as before; `POST /organization/add-member`, which on a managed environment admits exactly a platform administrator, adding a membership, to restore one the environment lost; and the organization doors that write no membership row (teams, invitations, the active organization, the organization's own fields) or only read. diff --git a/content/docs/permissions/authentication.mdx b/content/docs/permissions/authentication.mdx index d84e11237f9..e593728b4ca 100644 --- a/content/docs/permissions/authentication.mdx +++ b/content/docs/permissions/authentication.mdx @@ -1309,6 +1309,33 @@ sign-in through any other one leaves the person pending. Their positions, permis from the moment they are added, so seed data and approval flows can name them before they sign in. Off a managed environment both doors answer `409`. +On a cloud-managed environment the organisation that hosts it decides who is a +member and at which membership tier, so every organization door that writes or +deletes a membership row (the six below: removing a member, changing a member's tier +with Make Owner included, leaving, accepting an invitation, creating an +organization, which makes the caller its owner, and deleting one, which ends +every membership in it) answers `409 RESOURCE_CONFLICT` there and changes +nothing, and their seven actions are hidden. The one exception is +`POST /api/v1/auth/organization/add-member`, which admits exactly a platform +administrator, adding a membership, so the operator can restore one the +environment lost. The administrator names the membership tier in the request +body, where it is required (a request without it is refused `400`), and +ObjectStack passes it to better-auth unchanged. A signed-in caller who is not a platform +administrator is refused `403 PERMISSION_DENIED`, and a caller with no session +is answered `401 UNAUTHENTICATED`. The other +organization doors write no membership row (teams, invitations, the active +organization, the organization's own fields) or only read, and answer as before. + +{/* os:vendor-wire better-auth */} +```http +POST /api/v1/auth/organization/remove-member +POST /api/v1/auth/organization/update-member-role +POST /api/v1/auth/organization/leave +POST /api/v1/auth/organization/accept-invitation +POST /api/v1/auth/organization/create +POST /api/v1/auth/organization/delete +``` + Signing in does not lock the manager: a platform administrator still changes it with **Set Manager** (`POST /api/v1/auth/admin/set-user-manager`). That endpoint refuses only a person a SCIM directory holds, whose manager is changed diff --git a/packages/platform-objects/src/feature-gate-guard.test.ts b/packages/platform-objects/src/feature-gate-guard.test.ts index 49ce7e50945..6747346bd4e 100644 --- a/packages/platform-objects/src/feature-gate-guard.test.ts +++ b/packages/platform-objects/src/feature-gate-guard.test.ts @@ -264,11 +264,12 @@ describe('feature-gate completeness guard (#2874)', () => { } it('finds the gated surface (guards the walker itself)', () => { - // 37 booked inputs exist today (38 before #9968 retired - // sys_user.actions.set_user_role); if the walker ever goes blind and - // finds none, the it.each below would vacuously pass — pin a floor - // instead. - expect(referencedInputs.length).toBeGreaterThanOrEqual(37); + // 44 booked inputs exist today (37 before the seven membership actions + // were hidden while cloud-managed; 38 before #9968 + // retired sys_user.actions.set_user_role); if the walker ever goes + // blind and finds none, the it.each below would vacuously pass — pin a + // floor instead. + expect(referencedInputs.length).toBeGreaterThanOrEqual(44); }); it.each(referencedInputs)('%s references registered flag %s and is booked', (path, flag) => { diff --git a/packages/platform-objects/src/identity/action-predicate-sparse-face.test.ts b/packages/platform-objects/src/identity/action-predicate-sparse-face.test.ts index 1b40d2692b6..ac5201fec2a 100644 --- a/packages/platform-objects/src/identity/action-predicate-sparse-face.test.ts +++ b/packages/platform-objects/src/identity/action-predicate-sparse-face.test.ts @@ -106,6 +106,9 @@ function sourceOf(raw: unknown): string | undefined { const FEATURES = { organization: true, multiOrgEnabled: true, twoFactor: true, oidcProvider: true, admin: true, phoneNumber: true, apiKey: true, sso: true, + // The one hide-when-on flag the swept actions read: off is its "on" here, + // the setting that leaves the record half reachable. + cloudManaged: false, }; /** Evaluate through the canonical engine; a fault is reported, never thrown. */ diff --git a/packages/platform-objects/src/identity/cloud-managed-visibility.test.ts b/packages/platform-objects/src/identity/cloud-managed-visibility.test.ts index f3574a6d8b7..fdaca70b925 100644 --- a/packages/platform-objects/src/identity/cloud-managed-visibility.test.ts +++ b/packages/platform-objects/src/identity/cloud-managed-visibility.test.ts @@ -200,3 +200,96 @@ describe('features.cloudManaged offers the two doors that add a pending person', expect(offeredSites).toEqual(SIX.map(([site]) => site)); }); }); + +/** + * Membership and roles on a cloud-managed environment are managed by the + * organisation that hosts it, so the three row actions that change them are + * hidden while the flag is on: Change Role and Make Owner (both call + * update-member-role) and Remove Member (remove-member), each of whose doors + * refuses there. Each is offered as before when the flag is off. Add Member + * stays offered to a platform administrator on a managed environment: its + * door is the one left open, to restore a membership the environment lost. + */ +describe('features.cloudManaged hides the row actions that change a membership or its role', () => { + const MEMBER_ROW = { id: 'mem_1', user_id: 'u_member', organization_id: 'org_1', role: 'member' }; + const THREE: ReadonlyArray<[string]> = [['update_member_role'], ['remove_member'], ['transfer_ownership']]; + + const rowOffered = (name: string, features: Record): boolean | string => { + const r = celEngine.evaluate( + { dialect: 'cel', source: visibleOf(SysMember, name) }, + { record: MEMBER_ROW, extra: { current_user: ADMIN, user: ADMIN, ctx: { user: ADMIN }, features } }, + ); + if (!r.ok) return `FAULT ${r.error.message.split('\n')[0].trim()}`; + return typeof r.value === 'boolean' ? r.value : `NON-BOOLEAN ${JSON.stringify(r.value)}`; + }; + + it.each(THREE)('sys_member.%s is hidden while the environment is cloud-managed', (name) => { + expect(rowOffered(name, { ...OTHER_FLAGS, cloudManaged: true })).toBe(false); + }); + + it.each(THREE)('sys_member.%s is offered to the owner as before when the flag is off', (name) => { + expect(rowOffered(name, { ...OTHER_FLAGS, cloudManaged: false })).toBe(true); + }); + + it.each(THREE)('sys_member.%s keeps its organization gate: off hides it whatever cloudManaged says', (name) => { + expect(rowOffered(name, { organization: false, admin: true, cloudManaged: false })).toBe(false); + }); + + it('sys_member.add_member stays offered to a platform administrator while the environment is cloud-managed', () => { + expect(rowOffered('add_member', { ...OTHER_FLAGS, cloudManaged: true })).toBe(true); + }); +}); + +/** + * The rest of the membership census: every other action whose door writes or + * deletes a membership row is hidden while the flag is on, each offered as + * before when it is off. Leave Organization ends the caller's membership, + * Create Organization makes the caller an owner, Delete Organization ends + * every membership of the organization, and Accept Invitation creates one. + * Decline Invitation writes no membership, so it is not gated. + */ +describe('features.cloudManaged hides every other action whose door writes or deletes a membership row', () => { + const ORG_ROW = { id: 'org_1', name: 'Org', slug: 'org' }; + const INVITATION_ROW = { id: 'inv_1', email: ADMIN.email, status: 'pending', role: 'member', organization_id: 'org_1' }; + const MULTI = { ...OTHER_FLAGS, multiOrgEnabled: true }; + const FOUR: ReadonlyArray<[string, { actions?: unknown }, string, Record]> = [ + ['sys_organization.leave_organization', SysOrganization, 'leave_organization', ORG_ROW], + ['sys_organization.create_organization', SysOrganization, 'create_organization', {}], + ['sys_organization.delete_organization', SysOrganization, 'delete_organization', ORG_ROW], + ['sys_invitation.accept_invitation', SysInvitation, 'accept_invitation', INVITATION_ROW], + ]; + + const offeredOn = (def: { actions?: unknown }, name: string, record: Record, features: Record): boolean | string => { + const r = celEngine.evaluate( + { dialect: 'cel', source: visibleOf(def, name) }, + { record, extra: { current_user: ADMIN, user: ADMIN, ctx: { user: ADMIN }, features } }, + ); + if (!r.ok) return `FAULT ${r.error.message.split('\n')[0].trim()}`; + return typeof r.value === 'boolean' ? r.value : `NON-BOOLEAN ${JSON.stringify(r.value)}`; + }; + + it.each(FOUR)('%s is hidden while the environment is cloud-managed', (_site, def, name, record) => { + expect(offeredOn(def, name, record, { ...MULTI, cloudManaged: true })).toBe(false); + }); + + it.each(FOUR)('%s is offered as before when the flag is off', (_site, def, name, record) => { + expect(offeredOn(def, name, record, { ...MULTI, cloudManaged: false })).toBe(true); + }); + + // Each keeps its other gate: the three organization actions their + // `multiOrgEnabled` gate, Accept Invitation its pending-row predicate. + const OTHER_GATE_OFF: ReadonlyArray<[string, { actions?: unknown }, string, Record, Record]> = [ + ['sys_organization.leave_organization', SysOrganization, 'leave_organization', ORG_ROW, { ...OTHER_FLAGS, multiOrgEnabled: false, cloudManaged: false }], + ['sys_organization.create_organization', SysOrganization, 'create_organization', {}, { ...OTHER_FLAGS, multiOrgEnabled: false, cloudManaged: false }], + ['sys_organization.delete_organization', SysOrganization, 'delete_organization', ORG_ROW, { ...OTHER_FLAGS, multiOrgEnabled: false, cloudManaged: false }], + ['sys_invitation.accept_invitation', SysInvitation, 'accept_invitation', { ...INVITATION_ROW, status: 'accepted' }, { ...MULTI, cloudManaged: false }], + ]; + + it.each(OTHER_GATE_OFF)('%s keeps its other gate: closed, it hides the action whatever cloudManaged says', (_site, def, name, record, features) => { + expect(offeredOn(def, name, record, features)).toBe(false); + }); + + it('sys_invitation.reject_invitation, which writes no membership, stays offered while the environment is cloud-managed', () => { + expect(offeredOn(SysInvitation, 'reject_invitation', INVITATION_ROW, { ...MULTI, cloudManaged: true })).toBe(true); + }); +}); diff --git a/packages/platform-objects/src/identity/sys-invitation.object.ts b/packages/platform-objects/src/identity/sys-invitation.object.ts index 81560437a0c..4a46d3758c8 100644 --- a/packages/platform-objects/src/identity/sys-invitation.object.ts +++ b/packages/platform-objects/src/identity/sys-invitation.object.ts @@ -251,7 +251,10 @@ export const SysInvitation = ObjectSchema.create({ type: 'api', target: '/api/v1/auth/organization/accept-invitation', recordIdParam: 'invitationId', - visible: "has(record.email) && record.email == ctx.user.email && has(record.status) && record.status == 'pending'", + // Hidden while cloud-managed: accepting creates a membership, which is + // the hosting organisation's there; the door refuses (409 + // RESOURCE_CONFLICT). Decline stays: it writes no membership. + visible: "has(record.email) && record.email == ctx.user.email && has(record.status) && record.status == 'pending' && features.cloudManaged != true", successMessage: 'Invitation accepted', refreshAfter: true, // ADR-0011 identity-actions note, bucket E: exposed by plain declaration. diff --git a/packages/platform-objects/src/identity/sys-member.object.ts b/packages/platform-objects/src/identity/sys-member.object.ts index ab0d3441c65..ddd03e71b43 100644 --- a/packages/platform-objects/src/identity/sys-member.object.ts +++ b/packages/platform-objects/src/identity/sys-member.object.ts @@ -228,6 +228,9 @@ export const SysMember = ObjectSchema.create({ type: 'api', target: '/api/v1/auth/organization/update-member-role', recordIdParam: 'memberId', + // Hidden while cloud-managed: the hosting organisation manages members + // and their roles there, and the door refuses (409 RESOURCE_CONFLICT). + visible: 'features.cloudManaged != true', requiresFeature: 'organization', requiresMembershipReach: 'update_member_role', successMessage: 'Member role updated', @@ -254,6 +257,8 @@ export const SysMember = ObjectSchema.create({ type: 'api', target: '/api/v1/auth/organization/remove-member', recordIdParam: 'memberIdOrEmail', + // Hidden while cloud-managed, as `update_member_role` above. + visible: 'features.cloudManaged != true', requiresFeature: 'organization', requiresMembershipReach: 'remove_member', confirmText: 'Remove this member from the organization? They will lose access to all org resources.', @@ -301,7 +306,9 @@ export const SysMember = ObjectSchema.create({ // predicate at key resolution and drop the button silently. `has()` // alone — the operand is a bare equality against a literal (see // `materializeDeclaredFields` in `@objectstack/objectql`). - visible: "has(record.role) && record.role != 'owner'", + // Hidden while cloud-managed, as `update_member_role` above (the same + // door). + visible: "has(record.role) && record.role != 'owner' && features.cloudManaged != true", requiresFeature: 'organization', requiresMembershipReach: 'transfer_ownership', confirmText: 'Make the selected member an owner of this organization? They get every owner privilege, including deleting the organization. You stay an owner too; to step down, use Change Role on your own membership.', diff --git a/packages/platform-objects/src/identity/sys-organization.object.ts b/packages/platform-objects/src/identity/sys-organization.object.ts index 5725023818d..01ed4415973 100644 --- a/packages/platform-objects/src/identity/sys-organization.object.ts +++ b/packages/platform-objects/src/identity/sys-organization.object.ts @@ -71,6 +71,10 @@ export const SysOrganization = ObjectSchema.create({ locations: ['list_toolbar'], type: 'api', target: '/api/v1/auth/organization/create', + // Hidden while cloud-managed: creating an organization makes the caller + // its owner, and membership is the hosting organisation's there; the + // door refuses (409 RESOURCE_CONFLICT). + visible: 'features.cloudManaged != true', successMessage: 'Organization created', refreshAfter: true, // Hidden when the deployment is provisioned in single-org mode @@ -132,6 +136,9 @@ export const SysOrganization = ObjectSchema.create({ type: 'api', target: '/api/v1/auth/organization/delete', recordIdParam: 'organizationId', + // Hidden while cloud-managed: deleting ends every membership, and the + // door refuses there (409 RESOURCE_CONFLICT). + visible: 'features.cloudManaged != true', requiresFeature: 'multiOrgEnabled', // `organization/delete` admits the owner alone (ADR-0108 D1). requiresMembershipReach: 'delete_organization', @@ -242,6 +249,9 @@ export const SysOrganization = ObjectSchema.create({ type: 'api', target: '/api/v1/auth/organization/leave', recordIdParam: 'organizationId', + // Hidden while cloud-managed: leaving ends a membership, which is the + // hosting organisation's there; the door refuses (409 RESOURCE_CONFLICT). + visible: 'features.cloudManaged != true', requiresFeature: 'multiOrgEnabled', // Names what is lost (#24021's copy half, ruling 6228318638 item 2). confirmText: 'Leave this organization? You will lose access to its environments and members.', diff --git a/packages/platform-objects/src/platform-objects.test.ts b/packages/platform-objects/src/platform-objects.test.ts index 342cb25e2a0..a9c80336b27 100644 --- a/packages/platform-objects/src/platform-objects.test.ts +++ b/packages/platform-objects/src/platform-objects.test.ts @@ -743,16 +743,18 @@ describe('feature-gate lowering matrix (#2874)', () => { const MANAGED_ON = 'has(features.cloudManaged) && features.cloudManaged == true'; const rows: Array<[string, { actions?: readonly { name?: string; visible?: unknown; params?: readonly unknown[] }[] }, string, string]> = [ - ['SysOrganization', SysOrganization, 'create_organization', MULTI_ORG], + // Hidden while cloud-managed: create makes the caller an owner, and + // membership is the hosting organisation's there. + ['SysOrganization', SysOrganization, 'create_organization', `(${MANAGED}) && ${MULTI_ORG}`], // Their doors are better-auth's `organization/update` (owner, admin) and // `organization/delete` (owner), so the grade term leads the feature gate. ['SysOrganization', SysOrganization, 'update_organization', `${ADMINS} && ${MULTI_ORG}`], // [#25347] The name/logo-only rename is on the capability: under `single` // it is the one organization's only name door. ['SysOrganization', SysOrganization, 'rename_organization', `${ADMINS} && ${ORG}`], - ['SysOrganization', SysOrganization, 'delete_organization', `(${OWNER}) && ${MULTI_ORG}`], + ['SysOrganization', SysOrganization, 'delete_organization', `((${MANAGED}) && ${OWNER}) && ${MULTI_ORG}`], ['SysOrganization', SysOrganization, 'set_active_organization', MULTI_ORG], - ['SysOrganization', SysOrganization, 'leave_organization', MULTI_ORG], + ['SysOrganization', SysOrganization, 'leave_organization', `(${MANAGED}) && ${MULTI_ORG}`], ['SysUser', SysUser, 'invite_user', `((${MANAGED}) && ${INVITE}) && ${ORG}`], ['SysUser', SysUser, 'create_user', `(${STANDING} && ${MANAGED}) && features.admin == true`], // Their managed counterparts carry no feature gate (their doors mount @@ -781,12 +783,18 @@ describe('feature-gate lowering matrix (#2874)', () => { ['SysSsoProvider', SysSsoProvider, 'edit_sso_groups_claim', STANDING], ['SysSsoProvider', SysSsoProvider, 'show_sso_attribute_mapping', STANDING], ['SysSsoProvider', SysSsoProvider, 'edit_sso_attribute_mapping', STANDING], - ['SysMember', SysMember, 'update_member_role', `${ADMINS} && ${ORG}`], - ['SysMember', SysMember, 'remove_member', `${ADMINS} && ${ORG}`], - ['SysMember', SysMember, 'transfer_ownership', `((has(record.role) && record.role != 'owner') && ${OWNER}) && ${ORG}`], + // Hidden while cloud-managed: membership and its tiers are the hosting + // organisation's there, and both doors refuse. + ['SysMember', SysMember, 'update_member_role', `((${MANAGED}) && ${ADMINS}) && ${ORG}`], + ['SysMember', SysMember, 'remove_member', `((${MANAGED}) && ${ADMINS}) && ${ORG}`], + ['SysMember', SysMember, 'transfer_ownership', `((has(record.role) && record.role != 'owner' && ${MANAGED}) && ${OWNER}) && ${ORG}`], ['SysInvitation', SysInvitation, 'invite_user', `((${MANAGED}) && ${INVITE}) && ${ORG}`], ['SysInvitation', SysInvitation, 'cancel_invitation', `${ADMINS} && ${ORG}`], ['SysInvitation', SysInvitation, 'resend_invitation', `((${MANAGED}) && ${INVITE}) && ${ORG}`], + // No feature gate to lower: the authored pending-row predicate is served + // as written, with the cloud-managed conjunct (accepting creates a + // membership, which the hosting organisation manages there). + ['SysInvitation', SysInvitation, 'accept_invitation', `has(record.email) && record.email == ctx.user.email && has(record.status) && record.status == 'pending' && ${MANAGED}`], ['SysTeam', SysTeam, 'create_team', `${ADMINS} && ${ORG}`], ['SysTeam', SysTeam, 'update_team', `${ADMINS} && ${ORG}`], ['SysTeam', SysTeam, 'remove_team', `${ADMINS} && ${ORG}`], diff --git a/packages/plugins/plugin-auth/src/auth-manager-before-hook.ts b/packages/plugins/plugin-auth/src/auth-manager-before-hook.ts index a5cd29986c9..8fd782bfeaf 100644 --- a/packages/plugins/plugin-auth/src/auth-manager-before-hook.ts +++ b/packages/plugins/plugin-auth/src/auth-manager-before-hook.ts @@ -12,7 +12,8 @@ * it stood, re-indented four levels and otherwise unedited: the same actor * resolver handed to the attribution scope, the same refresh skip for a minted * principal session, the same per-number OTP send guard, the same password - * complexity and reuse checks, the same + * complexity and reuse checks, the cloud-managed refusal on the two doors that + * change a membership or its role (added after the move), the same * remove-member, organization-delete and no-record revoke refusals, the same * held-caller refusal on the admin plugin's role-scalar actions, the same * no-record admin revoke refusal, the same held-caller refusal on rewriting or @@ -123,6 +124,30 @@ const CLOUD_MANAGED_RESET_DOORS: ReadonlySet = new Set([ '/phone-number/request-password-reset', ]); +/** + * Every organization-family door that writes or deletes an organization + * membership row, which a cloud-managed environment refuses: the + * organisation that hosts it manages membership and its tiers. Make Owner + * (`sys_member.transfer_ownership`) sends the owner tier to + * update-member-role, so it is refused there; create makes the caller the + * new organization's owner, and delete ends every membership of the + * organization. `/organization/add-member` (exactly a platform administrator, + * adding a membership) is deliberately absent: it restores a membership the + * environment lost. The census of the family, with each other route's reason, + * is `cloud-managed.ts`'s header. + */ +const CLOUD_MANAGED_MEMBERSHIP_DOORS: ReadonlyMap< + string, + 'removeMember' | 'updateMemberRole' | 'leaveOrganization' | 'acceptInvitation' | 'createOrganization' | 'deleteOrganization' +> = new Map([ + ['/organization/remove-member', 'removeMember'], + [UPDATE_MEMBER_ROLE_PATH, 'updateMemberRole'], + ['/organization/leave', 'leaveOrganization'], + ['/organization/accept-invitation', 'acceptInvitation'], + ['/organization/create', 'createOrganization'], + [ORGANIZATION_DELETE_PATH, 'deleteOrganization'], +]); + /** * The `AuthManager` members the function below reads — every one of them, and * no other. Each is typed AS the class member (an indexed access on the @@ -374,6 +399,32 @@ export async function globalBeforeHook( // fall through to the path's own handling below } + // ── Cloud-managed: membership and its tiers are the hosting organisation's ── + // On a cloud-managed environment the organisation that hosts it manages + // who is a member and at which tier, so every door that writes or deletes + // an organization membership row (`CLOUD_MANAGED_MEMBERSHIP_DOORS`: + // remove-member, update-member-role with Make Owner, leave, + // accept-invitation, create, delete) refuses every request with the + // invite-member envelope (`cloud-managed.ts`), ahead of the vendor's + // handler: nothing is written. AHEAD of the remove-member permission arm, + // the organization-delete records arm and the role-change grant read below, + // so a refused request runs none of them. As with invite-member, the fact + // is public (`features.cloudManaged` on `/auth/config`), so answering it + // ahead of the session check tells an anonymous caller nothing new. + // add-member is not among these doors. This line is the only one: the + // invitation refusal has a second line in `beforeCreateInvitation`, but no + // in-process caller reaches these vendor operations (each is reached + // through its route alone, so through this hook), so one line is enough + // today. A future in-process caller of one of them needs its own refusal. + const membershipDoor = CLOUD_MANAGED_MEMBERSHIP_DOORS.get(ctx?.path ?? ''); + if (membershipDoor && isCloudManaged()) { + const { APIError } = await import('better-auth/api'); + throw new APIError('CONFLICT', { + message: CLOUD_MANAGED_REFUSAL_MESSAGES[membershipDoor], + code: CLOUD_MANAGED_REFUSAL_CODE, + }); + } + // ── #8289: remove-member answers its PERMISSION denial itself ── // better-auth's `removeMember` orders "only an owner may remove an // owner" AHEAD of its real permission check and reports it with the diff --git a/packages/plugins/plugin-auth/src/cloud-managed.test.ts b/packages/plugins/plugin-auth/src/cloud-managed.test.ts index ca583317d6a..88621b4d096 100644 --- a/packages/plugins/plugin-auth/src/cloud-managed.test.ts +++ b/packages/plugins/plugin-auth/src/cloud-managed.test.ts @@ -223,10 +223,10 @@ beforeAll(async () => { * staging gave, so no case sees another's writes. The tests switch the mode * on afterwards: every door under test reads the accessor per request. */ -async function stage() { +async function stage(extra: Record = {}) { const engine = createMemoryEngine(); for (const [name, rows] of structuredClone(staged.tables)) engine.tables.set(name, rows); - const manager = makeManager(engine); + const manager = makeManager(engine, extra); const { ids, bearers } = staged; const users = () => (engine.tables.get('sys_user') ?? []) as any[]; @@ -799,6 +799,268 @@ describe('SSO-only mode keeps IdP-provisioned users off local passwords at the s }); }); +// ───────────────────────────────────────────────────────────────────────────── +// Membership and roles +// ───────────────────────────────────────────────────────────────────────────── + +/** + * On a cloud-managed environment the organisation that hosts it manages who + * is a member and at which tier. Every organization door that writes or + * deletes a membership row refuses with the invite-member envelope and writes + * nothing: `remove-member`, `update-member-role` (Make Owner sends the owner + * tier to it), `leave`, `accept-invitation`, `create` (the caller would own + * the new organization) and `delete` (every membership would end). The arms + * behind the refusal (the remove-member permission judge, the role-change + * grant read, the organization-delete records judge) do not run. + * `add-member` stays open and admits exactly a platform administrator: it + * restores a membership the environment lost. Self-hosted, every door answers + * as before, and a door that writes no membership row (`reject-invitation`) + * answers as before on a managed environment too. + */ +describe('on a cloud-managed environment, membership and its tiers are managed by the hosting organisation', () => { + type Staged = Awaited>; + const memberships = (s: Staged) => + ((s.engine.tables.get('sys_member') ?? []) as any[]).filter((m) => m.organization_id === DEFAULT_ORG); + const membershipOf = (s: Staged, userId: string) => memberships(s).find((m) => String(m.user_id) === userId); + + /** The ordinary user's membership row, read before the case changes anything. */ + const memberRow = (s: Staged) => { + const row = membershipOf(s, s.ids.member); + expect(row, 'fixture invariant: the ordinary user holds a default-org membership').toBeDefined(); + expect(row.role, 'fixture invariant: as a plain member').toBe('member'); + return row; + }; + + type DoorPath = '/organization/remove-member' | '/organization/update-member-role'; + const DOORS: ReadonlyArray< + [string, DoorPath, 'removeMember' | 'updateMemberRole', (memberId: string) => Record] + > = [ + ['remove-member', '/organization/remove-member', 'removeMember', + (memberId) => ({ memberIdOrEmail: memberId, organizationId: DEFAULT_ORG })], + ['update-member-role', '/organization/update-member-role', 'updateMemberRole', + (memberId) => ({ memberId, role: 'admin', organizationId: DEFAULT_ORG })], + ['update-member-role to owner (Make Owner)', '/organization/update-member-role', 'updateMemberRole', + (memberId) => ({ memberId, role: 'owner', organizationId: DEFAULT_ORG })], + ]; + + it.each(DOORS)('%s answers 409 RESOURCE_CONFLICT to the owner, and the membership row is unchanged', async (_door, path, door, body) => { + const s = await stage(); + const row = memberRow(s); + const before = structuredClone(memberships(s)); + setManaged(true); + const v = await verdict(await s.fire(path, body(String(row.id)), s.bearers.admin)); + expectManagedRefusal(v, door); + expect(memberships(s)).toEqual(before); + }, 120_000); + + it.each(DOORS)('%s refuses ahead of the arms behind it: no permission judge runs and no grant read is taken', async (_door, path, _key, body) => { + const s = await stage(); + const row = memberRow(s); + const permissionJudge = vi.spyOn(s.manager as any, 'assertRemoveMemberPermitted'); + const grantRead = vi.spyOn(s.manager as any, 'roleChangeGrantDeps'); + setManaged(true); + const v = await verdict(await s.fire(path, body(String(row.id)), s.bearers.admin)); + expect(v.status, v.text).toBe(409); + expect(permissionJudge).not.toHaveBeenCalled(); + expect(grantRead).not.toHaveBeenCalled(); + }, 120_000); + + it.each(DOORS)('CONTROL: self-hosted, %s answers 200 and changes the membership as before', async (_door, path, _key, body) => { + const s = await stage(); + const row = memberRow(s); + const permissionJudge = vi.spyOn(s.manager as any, 'assertRemoveMemberPermitted'); + const grantRead = vi.spyOn(s.manager as any, 'roleChangeGrantDeps'); + const sent = body(String(row.id)); + const v = await verdict(await s.fire(path, sent, s.bearers.admin)); + expect(v.status, v.text).toBe(200); + if (path === '/organization/remove-member') { + expect(membershipOf(s, s.ids.member)).toBeUndefined(); + // The spy legs above are measured against arms that do run here. + expect(permissionJudge).toHaveBeenCalled(); + } else { + expect(membershipOf(s, s.ids.member)?.role).toBe(sent.role); + expect(grantRead).toHaveBeenCalled(); + } + }, 120_000); + + it('CONTROL: add-member still answers a platform administrator, and restores a membership the environment lost', async () => { + const s = await stage(); + const row = memberRow(s); + s.engine.tables.set( + 'sys_member', + ((s.engine.tables.get('sys_member') ?? []) as any[]).filter((m) => m.id !== row.id), + ); + expect(membershipOf(s, s.ids.member)).toBeUndefined(); + setManaged(true); + const v = await verdict( + await s.fire('/organization/add-member', { userId: s.ids.member, role: 'member', organizationId: DEFAULT_ORG }, s.bearers.admin), + ); + expect(v.status, v.text).toBe(200); + expect(membershipOf(s, s.ids.member)?.role).toBe('member'); + }, 120_000); + + it('CONTROL: invite-member keeps its own refusal, not a membership one', async () => { + const s = await stage(); + setManaged(true); + const v = await verdict( + await s.fire('/organization/invite-member', { + email: 'newcomer.membership@example.com', + role: 'member', + organizationId: DEFAULT_ORG, + }, s.bearers.admin), + ); + expectManagedRefusal(v, 'invitation'); + expect(s.invitationsOf('newcomer.membership@example.com')).toHaveLength(0); + }, 120_000); + + it('add-member admits exactly a platform administrator there: an ordinary member hears 403 PERMISSION_DENIED and nothing is written', async () => { + const s = await stage(); + const row = memberRow(s); + s.engine.tables.set( + 'sys_member', + ((s.engine.tables.get('sys_member') ?? []) as any[]).filter((m) => m.id !== row.id), + ); + const before = structuredClone(memberships(s)); + setManaged(true); + const v = await verdict( + await s.fire('/organization/add-member', { userId: s.ids.member, role: 'member', organizationId: DEFAULT_ORG }, s.bearers.member), + ); + expect(v.status, v.text).toBe(403); + expect(v.code, v.text).toBe('PERMISSION_DENIED'); + expect(memberships(s)).toEqual(before); + }, 120_000); + + // ── leave: a member ends their own membership ───────────────────────────── + + it('leave answers 409 RESOURCE_CONFLICT to a member, and their membership row is unchanged', async () => { + const s = await stage(); + memberRow(s); + const before = structuredClone(memberships(s)); + setManaged(true); + const v = await verdict(await s.fire('/organization/leave', { organizationId: DEFAULT_ORG }, s.bearers.member)); + expectManagedRefusal(v, 'leaveOrganization'); + expect(memberships(s)).toEqual(before); + }, 120_000); + + it('CONTROL: self-hosted, leave answers 200 and ends the membership as before', async () => { + const s = await stage(); + memberRow(s); + const v = await verdict(await s.fire('/organization/leave', { organizationId: DEFAULT_ORG }, s.bearers.member)); + expect(v.status, v.text).toBe(200); + expect(membershipOf(s, s.ids.member)).toBeUndefined(); + }, 120_000); + + // ── accept-invitation: an invitation still pending from before ──────────── + + /** The ordinary user, with no membership, holding a pending invitation issued while unmanaged. */ + const pendingInvitationFor = async (s: Staged): Promise => { + const row = memberRow(s); + s.engine.tables.set( + 'sys_member', + ((s.engine.tables.get('sys_member') ?? []) as any[]).filter((m) => m.id !== row.id), + ); + const email = String(s.users().find((u) => String(u.id) === s.ids.member)!.email); + const issued = await verdict( + await s.fire('/organization/invite-member', { email, role: 'member', organizationId: DEFAULT_ORG }, s.bearers.admin), + ); + expect(issued.status, `fixture: the invitation is issued while unmanaged — ${issued.text}`).toBe(200); + const [invitation] = s.invitationsOf(email); + expect(invitation?.status, 'fixture: the invitation is pending').toBe('pending'); + return String(invitation.id); + }; + + it('accept-invitation answers 409 RESOURCE_CONFLICT to the invitee: no membership is created and the invitation stays pending', async () => { + const s = await stage(); + const invitationId = await pendingInvitationFor(s); + setManaged(true); + const v = await verdict(await s.fire('/organization/accept-invitation', { invitationId }, s.bearers.member)); + expectManagedRefusal(v, 'acceptInvitation'); + expect(membershipOf(s, s.ids.member)).toBeUndefined(); + const invitation = ((s.engine.tables.get('sys_invitation') ?? []) as any[]).find((r) => String(r.id) === invitationId); + expect(invitation?.status).toBe('pending'); + }, 120_000); + + it('CONTROL: self-hosted, accept-invitation answers 200 and creates the membership as before', async () => { + const s = await stage(); + const invitationId = await pendingInvitationFor(s); + const v = await verdict(await s.fire('/organization/accept-invitation', { invitationId }, s.bearers.member)); + expect(v.status, v.text).toBe(200); + expect(membershipOf(s, s.ids.member)?.role).toBe('member'); + }, 120_000); + + // ── create and delete: an organization's owner membership, and every one ── + + const organizations = (s: Staged) => (s.engine.tables.get('sys_organization') ?? []) as any[]; + const allMemberships = (s: Staged) => (s.engine.tables.get('sys_member') ?? []) as any[]; + const SECOND_ORG = { name: 'Second Org', slug: 'second-org-membership' }; + /** A walled posture, where a second organization may be created at all. */ + const multiOrg = () => stage({ + getTenancy: () => ({ ...singleOrgTenancy(), posture: 'isolated', requestedPosture: 'isolated', isolationActive: true }), + }); + + it('create answers 409 RESOURCE_CONFLICT to the owner: no organization and no owner membership are written', async () => { + const s = await multiOrg(); + const orgsBefore = structuredClone(organizations(s)); + const membersBefore = structuredClone(allMemberships(s)); + setManaged(true); + const v = await verdict(await s.fire('/organization/create', SECOND_ORG, s.bearers.admin)); + expectManagedRefusal(v, 'createOrganization'); + expect(organizations(s)).toEqual(orgsBefore); + expect(allMemberships(s)).toEqual(membersBefore); + }, 120_000); + + it('CONTROL: self-hosted, create answers 200 and makes the caller the new organization\'s owner as before', async () => { + const s = await multiOrg(); + const v = await verdict(await s.fire('/organization/create', SECOND_ORG, s.bearers.admin)); + expect(v.status, v.text).toBe(200); + const org = organizations(s).find((o) => o.slug === SECOND_ORG.slug); + expect(org, v.text).toBeDefined(); + const owner = allMemberships(s).find((m) => m.organization_id === org.id && String(m.user_id) === s.ids.admin); + expect(owner?.role).toBe('owner'); + }, 120_000); + + it('delete answers 409 RESOURCE_CONFLICT to the owner, ahead of the records arm: the organization and its memberships remain', async () => { + const s = await multiOrg(); + const created = await verdict(await s.fire('/organization/create', SECOND_ORG, s.bearers.admin)); + expect(created.status, `fixture: the organization is created while unmanaged — ${created.text}`).toBe(200); + const org = organizations(s).find((o) => o.slug === SECOND_ORG.slug); + const orgsBefore = structuredClone(organizations(s)); + const membersBefore = structuredClone(allMemberships(s)); + const recordsArm = vi.spyOn(s.manager as any, 'assertOrganizationDeletable'); + setManaged(true); + const v = await verdict(await s.fire('/organization/delete', { organizationId: org.id }, s.bearers.admin)); + expectManagedRefusal(v, 'deleteOrganization'); + expect(recordsArm).not.toHaveBeenCalled(); + expect(organizations(s)).toEqual(orgsBefore); + expect(allMemberships(s)).toEqual(membersBefore); + }, 120_000); + + it('CONTROL: self-hosted, delete answers 200 and ends the organization\'s memberships as before', async () => { + const s = await multiOrg(); + const created = await verdict(await s.fire('/organization/create', SECOND_ORG, s.bearers.admin)); + expect(created.status, `fixture: the organization is created — ${created.text}`).toBe(200); + const org = organizations(s).find((o) => o.slug === SECOND_ORG.slug); + expect(allMemberships(s).some((m) => m.organization_id === org.id), 'fixture: the owner membership exists').toBe(true); + const recordsArm = vi.spyOn(s.manager as any, 'assertOrganizationDeletable'); + const v = await verdict(await s.fire('/organization/delete', { organizationId: org.id }, s.bearers.admin)); + expect(v.status, v.text).toBe(200); + expect(recordsArm).toHaveBeenCalled(); + expect(organizations(s).some((o) => o.id === org.id)).toBe(false); + expect(allMemberships(s).some((m) => m.organization_id === org.id)).toBe(false); + }, 120_000); + + // ── the rest of the family writes no membership row ─────────────────────── + + it('CONTROL: reject-invitation, which writes no membership, answers the invitee as before', async () => { + const s = await stage(); + const invitationId = await pendingInvitationFor(s); + setManaged(true); + const v = await verdict(await s.fire('/organization/reject-invitation', { invitationId }, s.bearers.member)); + expect(v.status, v.text).toBe(200); + expect(membershipOf(s, s.ids.member)).toBeUndefined(); + }, 120_000); +}); + describe('[#25083] what a host that mounts its own twin of a door imports', () => { // The cloud mounts a per-environment twin of `set-initial-password` // (objectstack-ai/cloud#3169). It takes the same arm from the package entry, diff --git a/packages/plugins/plugin-auth/src/cloud-managed.ts b/packages/plugins/plugin-auth/src/cloud-managed.ts index 857ae5f94e5..5d697901391 100644 --- a/packages/plugins/plugin-auth/src/cloud-managed.ts +++ b/packages/plugins/plugin-auth/src/cloud-managed.ts @@ -30,6 +30,20 @@ * break-glass clause, which kept a local credential reachable by population, * holds on self-hosted deployments only. * + * Membership and membership tiers are the hosting organisation's too. Every + * organization-family door that writes or deletes an organization membership + * row refuses every request, as `/organization/invite-member` does: + * `/organization/remove-member`, `/organization/update-member-role` (Make + * Owner included, which sends the owner tier to it), `/organization/leave`, + * `/organization/accept-invitation`, `/organization/create` (it makes the + * caller the new organization's owner) and `/organization/delete` (it ends + * every membership of the organization). The one door left open is + * `/organization/add-member`: it admits exactly a platform administrator, + * adding a membership, and is the operator's way to restore one the + * environment lost. The rest of the family writes no membership row (team + * rows, invitation rows, the session's active organization, the + * organization's own fields) or only reads, and answers as before. + * * Every refusal is `409 RESOURCE_CONFLICT`, no code minted — the answer * cloud-connection's platform-managed doors give, on the same rule: the * refusal comes from the runtime's state, not from the request (ADR-0112's @@ -83,6 +97,33 @@ export const CLOUD_MANAGED_REFUSAL_MESSAGES = { requestPasswordReset: "This environment is cloud-managed: you sign in through the hosting organisation's identity provider, and no " + 'local password is set or reset here for anyone, an administrator included. No reset link or code was sent.', + // `/organization/remove-member` (`sys_member.remove_member`). + removeMember: + 'This environment is cloud-managed: its members and their roles are managed in the organisation that hosts it, ' + + 'so a member cannot be removed here. Remove them in that organisation instead. No member was removed.', + // `/organization/update-member-role` (`sys_member.update_member_role` and + // `sys_member.transfer_ownership`, which sends the owner role to it). + updateMemberRole: + 'This environment is cloud-managed: its members and their roles are managed in the organisation that hosts it, ' + + "so a member's role cannot be changed here. Change it in that organisation instead. No role was changed.", + // `/organization/leave` (`sys_organization.leave_organization`). + leaveOrganization: + 'This environment is cloud-managed: its members and their roles are managed in the organisation that hosts it, ' + + 'so you cannot leave it here. Ask that organisation to remove you instead. No membership was ended.', + // `/organization/accept-invitation` (`sys_invitation.accept_invitation`). + acceptInvitation: + 'This environment is cloud-managed: its members and their roles are managed in the organisation that hosts it, ' + + 'so an invitation cannot be accepted here. Ask that organisation to add you instead. No membership was created.', + // `/organization/create` (`sys_organization.create_organization`), which + // makes the caller the new organization's owner. + createOrganization: + 'This environment is cloud-managed: its members and their roles are managed in the organisation that hosts it, ' + + 'so an organization, which would make you its owner, cannot be created here. No organization was created.', + // `/organization/delete` (`sys_organization.delete_organization`), which + // ends every membership of the organization. + deleteOrganization: + 'This environment is cloud-managed: its members and their roles are managed in the organisation that hosts it, ' + + 'so an organization, and every membership in it, cannot be deleted here. No organization was deleted.', } as const; /** The doors a cloud-managed environment narrows. */ diff --git a/packages/qa/dogfood/test/membership-required-every-posture.dogfood.test.ts b/packages/qa/dogfood/test/membership-required-every-posture.dogfood.test.ts index 4ca11423baf..2d783ebea9c 100644 --- a/packages/qa/dogfood/test/membership-required-every-posture.dogfood.test.ts +++ b/packages/qa/dogfood/test/membership-required-every-posture.dogfood.test.ts @@ -21,7 +21,11 @@ * `403 PERMISSION_DENIED` and nothing lands, and the key they minted is * refused; a flow they launch that runs as them reads none of the * organization's data and writes nothing; the other person — still a - * member — is served throughout, by the same doors and the same flows. + * member — is served throughout, by the same doors and the same flows; + * 4. a third person whose membership row is taken away by no door at all + * (under the system context) signs in to no active organization, adopts + * no membership, and reads and writes none of the organization's data, + * their own note included. * * The posture is read off the `tenancy` service, not assumed: a degraded boot * resolves to `single`, and a matrix whose walled legs were really `single` @@ -219,6 +223,47 @@ describe.each(['single', 'isolated', 'group'] as const)( expect(await readNotesByKey(stays.key)).toBe(200); }); + it('a person whose membership row is gone by no door signs in to no active organization and reads and writes none of its data', async () => { + // The row is taken away under the system context, not through any + // membership door: the state of a person the environment holds no + // membership for, however they arrived there. The person first writes a + // note as a member and reads it back, so the empty read below is + // measured against their own row. + const email = `membership.${posture}.no-row@example.com`; + await stack.signUp(email, PASSWORD, 'Membership no-row'); + const [u] = await findRows(ql, 'sys_user', { email }, 1); + const userId = String(u.id); + if (posture !== 'single') await ql.insert('sys_member', { user_id: userId, organization_id: orgId, role: 'member' }, { context: SYS }); + const row = await waitForMembership(ql, userId, orgId); + const asMember = await stack.signIn(email, PASSWORD); + const created = await stack.apiAs(asMember, 'POST', `/data/${NOTE}`, { title: 'no-row note, written as a member' }); + expect(created.status, await created.clone().text()).toBe(201); + const createdBody: any = await created.json(); + const noteId = String(createdBody?.data?.id ?? createdBody?.id ?? createdBody?.record?.id); + expect((await readNotes(asMember)).ids).toContain(noteId); + + await ql.delete('sys_member', { where: { id: row.id }, context: SYS }); + expect(await findRows(ql, 'sys_member', { user_id: userId }, 5)).toEqual([]); + + const token = await stack.signIn(email, PASSWORD); + const me = await stack.apiAs(token, 'GET', '/auth/get-session'); + expect(me.status, await me.clone().text()).toBe(200); + const meBody: any = await me.json(); + expect(meBody?.session?.activeOrganizationId ?? null, JSON.stringify(meBody?.session)).toBeNull(); + // Signing in adopted no membership either. + expect(await findRows(ql, 'sys_member', { user_id: userId }, 5)).toEqual([]); + + const read = await readNotes(token); + expect(read.status).toBe(200); + expect(read.ids).toEqual([]); + expect((await stack.apiAs(token, 'GET', `/data/${NOTE}/${noteId}`)).status).toBe(404); + + const write = await stack.apiAs(token, 'POST', `/data/${NOTE}`, { title: 'written with no membership row' }); + expect(write.status).toBe(403); + expect(errorCodeOf(await write.json())).toBe('PERMISSION_DENIED'); + expect(await findRows(ql, NOTE, { title: 'written with no membership row' }, 5)).toEqual([]); + }); + it('CONTROL: the person who is still a member is served — reads its note, and its write lands', async () => { const read = await readNotes(stays.token); expect(read.status).toBe(200); diff --git a/packages/qa/dogfood/test/org-change-slug-bound-action.dogfood.test.ts b/packages/qa/dogfood/test/org-change-slug-bound-action.dogfood.test.ts index ae8876d9e38..1b2e0e245a3 100644 --- a/packages/qa/dogfood/test/org-change-slug-bound-action.dogfood.test.ts +++ b/packages/qa/dogfood/test/org-change-slug-bound-action.dogfood.test.ts @@ -119,10 +119,14 @@ describe('a cloud-shaped composition binds change_slug to sys_organization, and it('carries the multiOrgEnabled gate, lowered as the platform lowers its own', () => { const changeSlug = actions.find((a) => a.name === 'change_slug'); - const leave = actions.find((a) => a.name === 'leave_organization'); + const setActive = actions.find((a) => a.name === 'set_active_organization'); expect(changeSlug?.visible).toEqual({ dialect: 'cel', source: featureGatePredicate('multiOrgEnabled') }); - // The platform's own multi-org action, gated by nothing else, serves the same predicate. - expect(changeSlug?.visible).toEqual(leave?.visible); + // The reference is `set_active_organization`: of the platform's own + // `sys_organization` actions it is the one whose only gate is + // `requiresFeature: 'multiOrgEnabled'` (no `visible` of its own, no + // membership reach), so its served predicate is the multi-org gate exactly + // as the platform lowers it, and nothing else. + expect(changeSlug?.visible).toEqual(setActive?.visible); }); it('the gate admits it with multi-org on and hides it with multi-org off', () => { diff --git a/packages/spec/src/kernel/public-auth-features.ts b/packages/spec/src/kernel/public-auth-features.ts index 5d1815c7699..ac22357dc66 100644 --- a/packages/spec/src/kernel/public-auth-features.ts +++ b/packages/spec/src/kernel/public-auth-features.ts @@ -302,11 +302,23 @@ export const PUBLIC_AUTH_FEATURES = { // Hidden in the console only: the server keeps answering it on an // `env_native` row, so the break-glass admin stays editable. 'sys_user.actions.set_user_password', + // Membership and its tiers are managed by the hosting organisation: + // every door that writes or deletes a membership row refuses (Make + // Owner rides update-member-role; create makes the caller an owner; + // delete ends every membership), add-member alone excepted. + 'sys_member.actions.update_member_role', + 'sys_member.actions.remove_member', + 'sys_member.actions.transfer_ownership', + 'sys_organization.actions.leave_organization', + 'sys_organization.actions.create_organization', + 'sys_organization.actions.delete_organization', + 'sys_invitation.actions.accept_invitation', ], notes: 'Served from the one isCloudManaged() accessor in @objectstack/core. ' + - 'Each gated input is also gated on `organization` or `admin`, so its ' + - '`visible` predicate carries two gates. Also read straight off ' + + 'Each gated input but sys_invitation.actions.accept_invitation is also ' + + 'gated on `organization`, `multiOrgEnabled` or `admin`, so its `visible` ' + + 'predicate carries two gates. Also read straight off ' + '/auth/config by objectui (the Setup → Users copy, the password reminder).', }, phoneNumberOtp: {