Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions docs/writing-an-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ async init () {

Other modules extend `_access` with their own keys (e.g. `_access.users`, `_access.groups`) and tap both hooks with additional grants, all OR-combined with the base `public` grant. Use `addAccessClause` (exported from `adapt-authoring-api`) for the query-level grant so observers compose safely with each other and with any user-driven `$or`.

`_access` carries an `_adapt.inputType: 'Access'` editor annotation so the authoring UI renders it as a single access widget rather than a raw object. A module adding a grant key should annotate its own sub-property too (e.g. an identity grant uses `_adapt.inputType: 'Principal'` with `options.apiRoot`/`labelField`/`kind`) so the widget can render it without any UI change.

`_access.public` defaults to `true` — resources are public unless a grant or the creating UI sets it otherwise. This preserves open access for resource types without a sharing UI; clients that scope access (e.g. the course wizard) set the value explicitly.

Enforcement is request-scoped: both hooks read `req.auth`/`req.apiData.query`, so `_access` is only applied to REST API requests. Internal/programmatic data access (e.g. server-side `find()`, preview, publish, export) bypasses it by design — there is no request identity to check against outside a REST request.
Expand Down
1 change: 1 addition & 0 deletions schema/access.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"_access": {
"type": "object",
"default": {},
"_adapt": { "inputType": "Access" },
"properties": {
"public": {
"description": "Whether the resource is accessible to all users",
Expand Down
Loading