Skip to content

Commit a6f0b7f

Browse files
os-zhuangclaude
andauthored
feat(serve): thread api.enforceProjectMembership to the dispatcher (ADR-0024 D9) (#2329)
serve.ts built the dispatcher with `scoping` but never threaded `enforceProjectMembership`, so per-project membership (the `sys_environment_member` 403 gate) was always forced ON whenever project-scoping was on. Read it from the app's `api` config and pass it through, so a host can opt OUT — env-native auth IS the membership (ADR-0024 D9) — via `api.enforceProjectMembership: false`. Undefined keeps the existing default (= `enableProjectScoping`): backward-compatible. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 8bb026b commit a6f0b7f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

packages/cli/src/commands/serve.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,11 @@ export default class Serve extends Command {
13541354
const apiConfig = (config as any).api ?? {};
13551355
const enableProjectScoping = apiConfig.enableProjectScoping ?? false;
13561356
const projectResolution = apiConfig.projectResolution ?? 'auto';
1357+
// Per-project membership (sys_environment_member 403 gate) is, by
1358+
// default, ON whenever project-scoping is on. A host can opt OUT
1359+
// (env-native auth IS the membership — ADR-0024 D9) by setting
1360+
// `api.enforceProjectMembership: false`. Undefined → dispatcher default.
1361+
const enforceProjectMembership = apiConfig.enforceProjectMembership;
13571362
// `requireAuth: true` rejects anonymous requests on `/api/v1/data/*`
13581363
// with HTTP 401 before they reach ObjectQL. Default-on when the
13591364
// stack opts in OR when the resolved tier set includes `auth`
@@ -1383,6 +1388,7 @@ export default class Serve extends Command {
13831388
await kernel.use(
13841389
createDispatcherPlugin({
13851390
scoping: { enableProjectScoping, projectResolution },
1391+
enforceProjectMembership,
13861392
observability,
13871393
}),
13881394
);

0 commit comments

Comments
 (0)