Repository navigation
Commit e2a4c66
fix(auth)!: a cloud-managed environment refuses remove-member and update-member-role (#34281)
Clause-②: no (narrowing)
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.
## 维护者速读
-
**改了什么**:云托管环境(`OS_CLOUD_MANAGED=1`)上,成员资格与成员等级由托管该环境的组织管理:组织族中凡写入或删除成员行的六扇门一律答
`409 RESOURCE_CONFLICT`
且不写任何东西(与邀请成员同一信封):移除成员、修改成员等级(含「设为所有者」)、离开组织、接受邀请、创建组织(创建者成为所有者)、删除组织(结束其全部成员资格);对应的七个操作在云托管时隐藏。唯一例外:`add-member`
只接纳平台管理员、只做「添加一条成员资格」,用于恢复环境丢失的成员资格。
-
**为什么改**:成员资格归托管组织所有,是已有邀请规则的同一条规则;组织族其余路由不写成员行(团队、邀请、当前组织、组织自身字段)或只读,照旧。自托管部署不受影响。
-
**风险与回滚**:属破坏性变更(BREAKING),只影响云托管环境:在环境内移除成员、改等级、离开、接受邀请、创建或删除组织的人改到托管组织去做。回滚即还原本
PR。
- **先看**:①
`packages/plugins/plugin-auth/src/auth-manager-before-hook.ts`(`CLOUD_MANAGED_MEMBERSHIP_DOORS`
六条与拒绝分支的位置:在 remove-member 权限分支、组织删除记录分支与改等级授权快照之前);②
`packages/plugins/plugin-auth/src/cloud-managed.ts`(族普查与六句拒绝文案);③
`packages/platform-objects/src/identity/`(七个 `visible`)。
- **两分钟验证**:`pnpm --filter @objectstack/plugin-auth exec vitest run
src/cloud-managed.test.ts`,预期全部通过:云托管下六扇门各答 409 且成员行不变,自托管下各照常 200
并改动成员行,非平台管理员调用 `add-member` 得 403。
- **需要你做的**:无,席位落地
## What changes
The rule: **on a cloud-managed environment, membership and membership
tiers are managed by the organisation that hosts it.** It extends the
invite-member rule already in place. Every organization-family door that
writes or deletes an organization membership row refuses; `add-member`
alone stays open.
- **plugin-auth: six doors refused.** On a cloud-managed environment,
each door below refuses every request with the envelope `invite-member`
already gives (`409 RESOURCE_CONFLICT`) and writes nothing.
`CLOUD_MANAGED_MEMBERSHIP_DOORS` in `auth-manager-before-hook.ts` lists
them, and the refusal comes ahead of the remove-member permission arm,
the organization-delete records arm and the role-change grant read, so
none of them runs on a refused request. Six sentences join
`CLOUD_MANAGED_REFUSAL_MESSAGES`: `removeMember`, `updateMemberRole`,
`leaveOrganization`, `acceptInvitation`, `createOrganization`,
`deleteOrganization`. This hook is the only line of refusal: no
in-process caller reaches these vendor operations. The hook comment says
so, and says that a future in-process caller needs its own refusal.
- **platform-objects: seven actions hidden.** `features.cloudManaged !=
true` now sits in `visible` on `sys_member.update_member_role`,
`remove_member` and `transfer_ownership`;
`sys_organization.leave_organization`, `create_organization` and
`delete_organization`; and `sys_invitation.accept_invitation`. The
invite actions are already hidden the same way.
- **spec.** `PUBLIC_AUTH_FEATURES.cloudManaged.gatedInputs` books the
seven paths. The registry note now names `accept_invitation` as the one
gated input that has no second feature gate. This is a list entry, not a
schema change, so `Metadata-protocol: none`.
- **The one exception.** `POST /organization/add-member` admits exactly
a platform administrator, adding a membership. On a managed environment
it restores a membership the environment lost; any other caller is
refused `403 PERMISSION_DENIED` (pinned).
- **Self-hosted** deployments never set the switch and answer exactly as
before.
- **Docs.** `content/docs/permissions/authentication.mdx` states the
rule in its cloud-managed section: the six doors, the seven hidden
actions, what add-member admits, and that the rest of the family is
unchanged. The six routes sit in a marked wire fence.
- **A membership pin.**
`membership-required-every-posture.dogfood.test.ts` gains a leg under
each tenancy posture. A person whose membership row was deleted under
the system context (no door) signs in to no active organization, adopts
no membership, and cannot read or write any of the organization's data,
their own note included.
### The organization family on a cloud-managed environment
Every `family: 'organization'` route in `auth-route-ledger.ts` (26
routes):
| Route | Disposition | Reason |
| --- | --- | --- |
| `POST /organization/remove-member` | refused (409) | deletes a
membership row |
| `POST /organization/update-member-role` | refused (409) | re-tiers a
membership row (Make Owner included) |
| `POST /organization/leave` | refused (409) | deletes the caller's
membership row |
| `POST /organization/accept-invitation` | refused (409) | creates a
membership row |
| `POST /organization/create` | refused (409) | creates the caller's
owner membership row |
| `POST /organization/delete` | refused (409) | deletes every membership
row of the organization |
| `POST /organization/add-member` | the exception | admits exactly a
platform administrator, adding a membership |
| `POST /organization/invite-member` | refused already (409) |
invitation rows; refused before this change |
| `POST /organization/cancel-invitation` | unchanged | invitation row
only |
| `POST /organization/reject-invitation` | unchanged | invitation row
only (pinned: answers 200 when managed) |
| `POST /organization/add-team-member` | out of scope | team rows only |
| `POST /organization/remove-team-member` | out of scope | team rows
only |
| `POST /organization/create-team` | out of scope | team rows only |
| `POST /organization/update-team` | out of scope | team row only |
| `POST /organization/remove-team` | out of scope | team rows only |
| `POST /organization/set-active` | unchanged | the session's active
organization, no membership row |
| `POST /organization/update` | unchanged | the organization's own
fields |
| `GET /organization/get-active-member` | unchanged | read |
| `GET /organization/get-full-organization` | unchanged | read |
| `GET /organization/list` | unchanged | read |
| `GET /organization/list-members` | unchanged | read |
| `GET /organization/list-invitations` | unchanged | read |
| `GET /organization/list-user-invitations` | unchanged | read |
| `GET /organization/list-teams` | unchanged | read |
| `GET /organization/list-team-members` | unchanged | read |
| `GET /organization/invitation-preview` | unchanged | read |
## Tests
- `plugin-auth/src/cloud-managed.test.ts` gains one top-level
`describe`. It runs on the real `AuthManager` behind the real route
mount; create and delete run on a walled posture, since `single` refuses
a second organization.
- On a managed environment, each of the six doors is refused with the
envelope (`code`, `status` and the door's own sentence), and the
membership rows are unchanged. For create, no organization is written
either; for delete, the organization stays.
- The arms behind the refusal never run (spied): the permission judge,
the grant read and the delete records judge.
- CONTROLS on self-hosted: each door answers `200` and changes the rows
(the spied arms run there).
- add-member still answers a platform administrator on a managed
environment and restores the row; an ordinary member is refused `403
PERMISSION_DENIED` there with nothing written.
- invite-member keeps its own refusal, and reject-invitation answers
`200` when managed.
- `platform-objects`:
- The feature-gate guard's forward rows now include the seven paths; the
walker floor goes from 37 to 44.
- The lowering matrix carries the new conjunct on the six action rows it
already had, and adds an `accept_invitation` row.
- `identity/cloud-managed-visibility.test.ts` evaluates the seven
predicates through the canonical CEL engine. Each is hidden when
managed, offered as before when not, and still hidden when its other
gate is closed (organization or `multiOrgEnabled`; the pending row for
accept). add-member stays offered when managed, and reject-invitation
too.
- The sparse-face sweep reads the new conjunct.
## Acceptance notes
- The docs page carried the managed refusals for create-user and
import-users, not invite-member; the rule went into that same
cloud-managed section.
- No skill under `skills/**` teaches these doors, so no skill moves.
## Verification
Readings at head `852c9a0e942bfc395181fa9739dd889144632c35`, under the
verify lock.
<details><summary>Rule suites, ablations, gates and the dogfood
battery</summary>
- `pnpm --filter @objectstack/plugin-auth exec vitest run
src/cloud-managed.test.ts`: Tests 59 passed (59).
- platform-objects pins (`feature-gate-guard`,
`identity/action-predicate-sparse-face`,
`identity/cloud-managed-visibility`, `platform-objects`): Test Files 4
passed (4), Tests 353 passed (353).
- `membership-required-every-posture.dogfood.test.ts`: Tests 21 passed
(21). `org-change-slug-bound-action.dogfood.test.ts`: Tests 5 passed
(5).
- Typecheck: `@objectstack/plugin-auth`, `@objectstack/platform-objects`
and `@objectstack/spec` each exit 0.
- **Ablation of the refusal arm** (`scripts/ablation-replace.mjs`, WRAP
on the membership-door arm of the before-hook):
`src/cloud-managed.test.ts` Tests 10 failed | 49 passed (59), the reds
being the refusal pins of the six doors and the refuse-ahead-of-the-arms
pins. Restored: blob equal to HEAD, `git diff HEAD` empty.
- **Ablation of the fixture correction** (the old cross-check put back):
`org-change-slug-bound-action.dogfood.test.ts` 1 failed | 4 passed.
Restored the same way.
- `dispatch-gates --commands` ∪ `--ran`: 116 derived, 116 run, 0
NOT-MEASURED, 0 UNRUN; the three prerequisite gates were run after
building their prerequisites (`check:skill-examples` 347 examples,
`check:dual-build-cjs-loads` 123 entry points across 72 packages,
`check:type-check-debt` OK).
- **Dogfood battery** (`pnpm --filter @objectstack/dogfood test`, no
shard, no path): Test Files 473 passed | 3 skipped (476), Tests 4006
passed | 42 skipped (4048), no failures.
- CI at this head: 59 success, 12 skipped, 0 failed.
</details>
Round 3 changes from `dc93845f`: the dogfood cross-check of the
multi-org gate now compares against `set_active_organization`, the one
`sys_organization` action whose only gate is `multiOrgEnabled`
(`leave_organization` now also carries the cloud-managed hide); the docs
say who names the tier of a membership added through add-member and that
a caller with no session is answered as unauthenticated; `origin/main`
merged without conflict.
---
_Generated by [Claude
Code](https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f)_
<!-- signed: security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 329f2f7 commit e2a4c66
15 files changed
Lines changed: 608 additions & 22 deletions
File tree
- .changeset
- content/docs/permissions
- packages
- platform-objects/src
- identity
- plugins/plugin-auth/src
- qa/dogfood/test
- spec/src/kernel
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1309 | 1309 | | |
1310 | 1310 | | |
1311 | 1311 | | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
1312 | 1339 | | |
1313 | 1340 | | |
1314 | 1341 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
272 | 273 | | |
273 | 274 | | |
274 | 275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
109 | 112 | | |
110 | 113 | | |
111 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
255 | 258 | | |
256 | 259 | | |
257 | 260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
231 | 234 | | |
232 | 235 | | |
233 | 236 | | |
| |||
254 | 257 | | |
255 | 258 | | |
256 | 259 | | |
| 260 | + | |
| 261 | + | |
257 | 262 | | |
258 | 263 | | |
259 | 264 | | |
| |||
301 | 306 | | |
302 | 307 | | |
303 | 308 | | |
304 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
305 | 312 | | |
306 | 313 | | |
307 | 314 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
| |||
132 | 136 | | |
133 | 137 | | |
134 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
135 | 142 | | |
136 | 143 | | |
137 | 144 | | |
| |||
242 | 249 | | |
243 | 250 | | |
244 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
245 | 255 | | |
246 | 256 | | |
247 | 257 | | |
| |||
0 commit comments