feat(rest): enforce object enable.apiEnabled / apiMethods (ADR-0049 #1889)#1937
Merged
Conversation
…1889) The metadata-liveness audit found object `enable.apiEnabled`/`apiMethods` parsed but NOT enforced by REST — an object could not be hidden from the automatic API despite the flag, a false sense of security. This wires them into the REST data surface (the external API boundary only — internal objectql/hooks/flows unaffected): - new RestServer.enforceApiAccess() loads object metadata and, per request: - enable.apiEnabled === false → 404 OBJECT_API_DISABLED (existence not revealed) - enable.apiMethods (non-empty whitelist) → unlisted op → 405 OBJECT_API_METHOD_NOT_ALLOWED - called across all 12 data entry points: list/get/create/query/update/delete/ import/export/batch/createMany/updateMany/deleteMany. - default-allow: no `enable` block, or apiEnabled unset/true + no apiMethods → no change (no regression). Unknown objects fall through to the normal 404. A metadata-read failure does not block (the data call needs the same metadata). 8 new tests (apiEnabled 404 on read+write, apiMethods 405/allow, no-regression default, unknown-object pass-through, bulk path). Full rest suite green (110). Closes the apiEnabled gap from object liveness; the gate now classifies enable.apiEnabled/apiMethods live (evidence: rest-server.ts). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 2 package(s): 89 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First enforce-or-remove fix from the metadata-liveness work (ADR-0049 #1889) — closing a real false-compliance security gap, not adding measurement.
The gap
The object liveness audit found
enable.apiEnabled/enable.apiMethodsparsed but never enforced by REST — an object could not be hidden from the automatic API despite the flag. AuthoringapiEnabled: falsewas a silent no-op (false sense of security).The fix
New
RestServer.enforceApiAccess()loads the object's metadata and, per request:enable.apiEnabled === false→ 404OBJECT_API_DISABLED(404 so existence isn't revealed)enable.apiMethods(non-empty whitelist) → operation outside it → 405OBJECT_API_METHOD_NOT_ALLOWEDWired across all 12 data entry points: list / get / create / query / update / delete / import / export / batch / createMany / updateMany / deleteMany.
Scope: the external REST API boundary only — internal callers (hooks, flows, raw objectql) are unaffected, which is correct:
apiEnabledgoverns automatic API exposure, not data access.No regression: default-allow — objects with no
enableblock (orapiEnabledunset/true and noapiMethodswhitelist) behave exactly as before. Unknown objects fall through to the normal 404. A metadata-read failure does not block (the data call needs the same metadata anyway).Tests
8 new tests:
apiEnabled:false→ 404 on read and write (engine never called),apiMethods405 + allow-through, no-regression default, explicitapiEnabled:true, unknown-object pass-through, and the bulk path. Full@objectstack/restsuite green (110).Liveness closure
The gate now classifies
object.enable.apiEnabled/apiMethodslive (evidence:rest-server.ts) instead of dead — the loop closes. Remainingenable.*flags (trackHistory/searchable/files/feeds/activities/trash/mru/clone) stay dead (separate enforce-or-remove items).🤖 Generated with Claude Code