Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5c1f929
test(plugin-auth): pin the membership doors on a cloud-managed enviro…
claude Nov 16, 2026
31e81c4
fix(plugin-auth)!: a cloud-managed environment refuses remove-member …
claude Nov 16, 2026
3288c0d
fix(platform-objects,spec)!: hide the membership-change actions while…
claude Nov 16, 2026
2267499
test(dogfood): pin that a person with no membership row reads no orga…
claude Nov 16, 2026
6d39893
Merge remote-tracking branch 'origin/main' into claude/cloud-managed-…
claude Nov 16, 2026
58e77a1
docs(auth): name the two membership doors in a marked wire fence
claude Nov 16, 2026
858d8b5
test(platform-objects): the lowering matrix and sparse-face sweep rea…
claude Nov 16, 2026
83d41f4
test(plugin-auth): spy on the two private arms through an untyped handle
claude Nov 16, 2026
87f6557
Merge remote-tracking branch 'origin/main' into claude/cloud-managed-…
claude Nov 16, 2026
83ae9a6
docs(plugin-auth): state the membership rule only in the cloud-manage…
claude Nov 16, 2026
5ace81e
test(dogfood): delete the membership row with the engine's where-shap…
claude Nov 16, 2026
def9a07
Merge remote-tracking branch 'origin/main' into claude/cloud-managed-…
claude Nov 16, 2026
6ad5572
fix(plugin-auth,platform-objects,spec)!: every door that writes or de…
claude Nov 16, 2026
1b22e67
test,docs: pin the full membership census on a cloud-managed environm…
claude Nov 16, 2026
6e53e34
test,docs: each new hide keeps its other gate; the docs name the six …
claude Nov 16, 2026
dc93845
test(platform-objects): the lowering matrix pins accept_invitation's …
claude Nov 16, 2026
d25bb9f
docs(permissions): add-member names its tier in the required role; no…
claude Nov 16, 2026
b012e9f
Merge remote-tracking branch 'origin/main' into claude/cloud-managed-…
claude Nov 16, 2026
74eb16d
test(dogfood): change_slug's multi-org cross-check reads set_active_o…
claude Nov 16, 2026
852c9a0
docs(permissions): name add-member's tier field without the reserved …
claude Nov 16, 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
19 changes: 19 additions & 0 deletions .changeset/cloud-managed-membership-changes-refused.md
Original file line number Diff line number Diff line change
@@ -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.

<!-- adr-0087: not-required (no-migration-prescription) No schema key, accepted value or metadata type is added, removed, renamed or re-shaped: seven paths join a feature-flag registry list, and the moved answers are runtime refusals at six auth doors under a deployment switch that only hosted environments set, so there is nothing stored for a migration to rewrite and no tombstone. -->

**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.
27 changes: 27 additions & 0 deletions content/docs/permissions/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions packages/platform-objects/src/feature-gate-guard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>): 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<string, unknown>]> = [
['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<string, unknown>, features: Record<string, unknown>): 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<string, unknown>, Record<string, unknown>]> = [
['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);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 8 additions & 1 deletion packages/platform-objects/src/identity/sys-member.object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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.',
Expand Down Expand Up @@ -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.',
Expand Down
10 changes: 10 additions & 0 deletions packages/platform-objects/src/identity/sys-organization.object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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.',
Expand Down
Loading
Loading