A reference for how datasette-paper does per-document access control. The intent is that a sibling plugin (one that wants per-resource sharing on top of some other domain object — places lists, sheets workbooks, …) can read this doc and reproduce the model.
Per-document access is owned by datasette-acl.
Paper declares a resource type and a set of roles; acl stores the grants and
answers the permission checks. Paper ships almost no permission SQL of its own —
the one exception is the read-only locked flag (see §5).
Three plugins collaborate:
| Plugin | Role |
|---|---|
| datasette-acl | stores grants, resolves paper-view/-edit/-manage against them, exposes the JSON API the share dialog drives |
| datasette-acl-share | the reusable <datasette-acl-share-dialog> web component — paper embeds it on the doc page; it grants/updates/revokes acl grants directly |
| datasette-user-profiles | (transitively, via the dialog) people search + avatars |
Paper itself only: declares the actions + roles + resource class, seeds an owner
grant on create, emits the locked deny, and runs an SSE revocation sweep when
the dialog mutates a grant.
| Action | Scope | Resolved by |
|---|---|---|
datasette-paper-create |
global | standard config-permissions (permissions: block) |
paper-view |
per-doc (PaperDocResource) |
datasette-acl grants |
paper-edit |
per-doc (PaperDocResource) |
datasette-acl grants; also_requires=paper-view; plus paper's locked deny |
paper-manage |
per-doc (PaperDocResource) |
datasette-acl grants (the Manager role); also_requires=paper-view |
Listing is not gated. The index, list, search and template-param endpoints
are reachable by anyone and return only the docs acl says the actor can view
(allowed_resources("paper-view")), so a coarse datasette-paper-list
permission would be redundant — there is no such action.
paper-manage is a real action now (it was an inline owner check in the
pre-acl model). It is the Manager-only capability — managing sharing, locking,
archiving, templating. The document owner gets it via a Manager grant seeded at
create time (§4).
One external action paper consults:
profile_access. Display-name / avatar resolution is gated on theprofile_accessaction owned by datasette-user-profiles, not by paper. It is not one of paper's four actions and paper never declares it — paper only consults it (datasette.allowed("profile_access", …)) before resolving actor ids to profiles, and degrades to id-as-name when it's denied (never 403). See §14 for the rule and §15 for which endpoints apply it. Noted here so the full gate surface lives in one place.
datasette_paper/__init__.py → register_actions:
from datasette.permissions import Action
from .permissions import PAPER_VIEW, PAPER_EDIT, PAPER_MANAGE
@hookimpl
def register_actions(datasette):
return [
# Global — config-driven. (Listing is ungated; there is no list action.)
Action(name="datasette-paper-create", description="Can create new papers"),
# Per-doc — acl-backed.
Action(name=PAPER_VIEW, description="View a paper doc",
resource_class=PaperDocResource),
Action(name=PAPER_EDIT, description="Edit a paper doc",
resource_class=PaperDocResource, also_requires=PAPER_VIEW),
Action(name=PAPER_MANAGE, description="Manage sharing for a paper doc",
resource_class=PaperDocResource, also_requires=PAPER_VIEW),
](PAPER_VIEW / PAPER_EDIT / PAPER_MANAGE are the action-name constants
exported by permissions.py — import them rather than re-typing the strings.)
Things to know:
also_requires=is honoured automatically bydatasette.ensure_permissionanddatasette.allowed— no manual chaining in route handlers.resource_class=PaperDocResourcemarks the action per-resource. A check with aresource=argument consults datasette-acl's grants (and paper'spermission_resources_sql); without one it falls back to global config rules.- The global
datasette-paper-createaction stays config-driven (thepermissions:block); the three per-doc actions are answered by acl grants, not by paper SQL.
datasette-acl resolves an action check by matching the actor's granted actions
against the roles a plugin registers for its resource type. Paper registers
the canonical cumulative triple via the datasette_acl_roles hook
(datasette_paper/__init__.py), using acl's standard_roles() factory rather
than hand-building each AclRole:
from datasette_acl.roles import standard_roles
@hookimpl
def datasette_acl_roles(datasette):
return standard_roles(
"paper-doc",
view=PAPER_VIEW, edit=PAPER_EDIT, manage=PAPER_MANAGE,
)standard_roles() returns Viewer (rank 1, paper-view), Editor (rank 2,
paper-view+paper-edit) and Manager (rank 3, manage=True, all three) — the
same cumulative bundles paper used to spell out by hand.
rankorders the roles (used by the share dialog's role dropdown).manage=Trueflags Manager as the role that may change sharing — acl uses it to decidecan_managein its JSON API, which drives the dialog's read-only vs editable rendering.
The share dialog grants/revokes roles (Viewer/Editor/Manager) or, for
General access, a public-audience principal (authenticated / everyone).
Paper never writes these — datasette-acl-share does, against acl's JSON API.
Per-doc actions resolve against PaperDocResource (datasette_paper/permissions.py):
from datasette.permissions import Resource
PAPER_DOC_RESOURCE_TYPE = "paper-doc"
PAPER_DOCS_PARENT = "_paper" # fixed sentinel — all docs share one parent
class PaperDocsParent(Resource):
name = "paper-docs-parent"
parent_class = None
@classmethod
async def resources_sql(cls, datasette, actor=None) -> str:
return f"SELECT '{PAPER_DOCS_PARENT}' AS parent, NULL AS child"
class PaperDocResource(Resource):
"""A single paper doc. Two-level: parent = sentinel, child = doc id."""
name = PAPER_DOC_RESOURCE_TYPE
parent_class = PaperDocsParent
def __init__(self, parent=None, child=None):
# Common path: PaperDocResource(doc_id) — the lone positional is the
# doc id, parent falls back to the sentinel. Two-arg form
# PaperDocResource(parent, child) is what acl.build_resource uses.
if child is None and parent is not None:
parent, child = PAPER_DOCS_PARENT, parent
elif parent is None:
parent = PAPER_DOCS_PARENT
super().__init__(parent=str(parent),
child=str(child) if child is not None else None)
@classmethod
async def resources_sql(cls, datasette, actor=None) -> str:
return (f"SELECT '{PAPER_DOCS_PARENT}' AS parent, "
"CAST(id AS TEXT) AS child FROM _datasette_paper_doc")Why two levels when every paper lives in one internal database?
- datasette-acl models resources as
(resource_type, parent, child). A real parent row lets a general-access grant target "all paper docs" via the parent if ever wanted, and keeps paper consistent with table-style two-level resources. - The parent is a fixed sentinel string (
_paper), not a database name. The doc id is thechild. This is the inverse of the old single-level model, where the doc id lived inparentwithchild=None. resources_sqlis the enumeration query used bydatasette.allowed_resources(...): columnsparent+child, noallow, no rules — just the universe of docs the action can apply to.
The string wrapping (str(...), CAST(id AS TEXT)) is deliberate: acl compares
the child as text, so both sides of the join must be text.
There is no "owner" permission rule. Ownership is an acl Manager grant seeded
when a doc is created (datasette_paper/permissions.py):
async def seed_owner_manager_grant(datasette, doc_id, created_by) -> None:
if not created_by: # anonymous never owns
return
await _acl_grant(
datasette, PAPER_DOC_RESOURCE_TYPE, PAPER_DOCS_PARENT, str(doc_id),
principal=Principal.actor(str(created_by)),
role="Manager", by_actor=str(created_by),
)The create route calls it right after the insert (routes/docs.py):
doc = await db.insert_doc(..., created_by=actor_id(request))
# Owner gets the Manager role so they can view, edit, and manage sharing.
await seed_owner_manager_grant(datasette, doc.id, doc.created_by)No-op for anonymous creates (created_by falsy) — an anonymous owner is not
representable as a grant. Such docs have no grants and are reachable only if a
deployment grants paper-view/-edit globally (see §8) or a later signed-in
actor is granted access.
isOwner≠paper-manage.isOwneris still a plaindoc.created_by == actor_idcomparison, surfaced in response bodies for "by you" UI labels.paper-manageis the acl check. They usually coincide (the owner holds Manager) but are computed independently — don't gate writes onisOwner; gate on the action.
Paper keeps exactly one piece of permission SQL — the read-only locked flag,
which has no acl equivalent (datasette_paper/permissions.py):
@hookimpl
async def permission_resources_sql(datasette, actor, action):
if action != "paper-edit":
return None # acl + config answer everything else
# For every locked doc, emit a child-level DENY of paper-edit.
return [PermissionSQL(sql=(
f"SELECT '{PAPER_DOCS_PARENT}' AS parent, "
"CAST(id AS TEXT) AS child, 0 AS allow, 'locked' AS reason "
"FROM _datasette_paper_doc WHERE locked = 1"
))]How it composes:
- acl grants land at the child depth (a specific doc). This deny is also at the child depth. Deny beats allow at the same depth in core's rule resolver, so a lock wins over any grant — owner, editor, or general access.
- Only
paper-editis touched.paper-viewis untouched (locked docs are still readable) and so ispaper-manage, which is why the owner can still unlock. - The unlock route gates on view +
paper-manage, never on edit — gating unlock on edit would trap the owner of their own locked doc (the lock denies them edit too). See_ensure_ownerin §7.
Return None for any action you don't own: Datasette merges
permission_resources_sql across all plugins, so returning a list for an
unrelated action injects spurious rules into other plugins' decisions.
| Call | Use when |
|---|---|
await datasette.ensure_permission(action, resource=, actor=) |
Gate a route. Raises Forbidden → 403. |
await datasette.allowed(action, resource=, actor=) |
Bool check. Capability flags in response bodies, raw-ASGI handlers, runtime sweeps. |
await datasette.allowed_resources(action, actor=, limit=) |
Enumerate every doc the actor can act on (the index listing). |
Helpers (datasette_paper/permissions.py) wrap these so handlers read cleanly:
async def ensure_paper_view(datasette, request, doc_id):
await datasette.ensure_permission(
action="paper-view", resource=PaperDocResource(doc_id), actor=request.actor)
async def ensure_paper_edit(datasette, request, doc_id):
await datasette.ensure_permission(
action="paper-edit", resource=PaperDocResource(doc_id), actor=request.actor)
async def can_paper_view(datasette, actor, doc_id) -> bool: # bool form
return await datasette.allowed(
action="paper-view", resource=PaperDocResource(doc_id), actor=actor)
async def can_paper_edit(datasette, actor, doc_id) -> bool: ... # agent tools
async def can_paper_manage(datasette, actor, doc_id) -> bool: # share/owner ops
return await datasette.allowed(
action="paper-manage", resource=PaperDocResource(doc_id), actor=actor)Every route handler calls the matching helper as its first awaited line:
@router.POST(r"^/-/paper/api/docs$") # create
async def create_doc(datasette, request):
await ensure_paper_create(datasette, request)
...
@router.POST(r"^/-/paper/api/docs/(?P<doc_id>\d+)/rename$") # edit (→ view via also_requires)
async def rename_doc(datasette, request, doc_id: int):
await ensure_paper_edit(datasette, request, doc_id)
...@router.GET(r"^/-/paper/api/docs$")
async def list_docs(datasette, request):
# No global gate — results are acl-filtered, so a no-grant actor gets [].
page = await datasette.allowed_resources(
action=PAPER_VIEW, actor=request.actor, limit=1000)
doc_ids = [int(r.child) for r in page.resources] # NOTE: child, not parent
....resources is a list of PaperDocResource-shaped instances — the doc id is now
in .child (the parent is the sentinel). limit caps the page; the page object
carries a continuation cursor for full pagination.
The open-doc envelope embeds capabilities so the frontend renders read-only UI
without extra round-trips (routes/docs.py):
is_owner = doc.created_by is not None and doc.created_by == me
can_edit = await datasette.allowed(action="paper-edit",
resource=PaperDocResource(doc_id), actor=request.actor)
can_manage = await can_paper_manage(datasette, request.actor, doc_id)
return Response.json({
...,
"permissions": {
"canView": True,
"canEdit": can_edit,
"canManage": can_manage, # acl Manager check — gates nothing on its own,
# the share dialog re-derives its own can_manage
"isOwner": is_owner, # inline created_by equality (UI label only)
"locked": bool(doc.locked),
},
})Streaming handlers (SSE) can't use ensure_permission (the Forbidden would
fire after the response has started). Use the bool form and write a 403 manually
(routes/events.py):
async def sse_events(datasette, request, send, receive):
if not await can_paper_view(datasette, request.actor, doc_id):
await _send_status(send, 403, b"Permission denied")
return
...Archive / trash / restore / lock / unlock / make_template all funnel through one
gate (routes/docs.py):
async def _ensure_owner(datasette, request, doc_id: int):
# View first (standardises the 403 surface + hides existence), then manage.
await ensure_paper_view(datasette, request, doc_id)
if not await can_paper_manage(datasette, request.actor, doc_id):
raise Forbidden("paper-manage")
doc = await paper_db(datasette).select_doc_by_id(doc_id)
return doc # None → caller 404sThe gate is view, not edit, on purpose: a locked doc denies edit to everyone
including the owner, so gating manage on edit would make a locked paper
un-unlockable. paper-manage (the owner's seeded Manager grant) is what actually
enforces ownership; the view pre-check just standardises the 403 and stops
doc-id probing from disclosing existence.
Forbidden("paper-manage")'s string is freeform — it shows in debug output;
the registered action is what's actually checked.
datasette --internal papers.db \
-s permissions.datasette-paper-create trueor in datasette.yaml:
permissions:
datasette-paper-create: trueThe value can be true (everyone), an actor-id object ({"id": "alice"}), or
any standard Datasette permission expression. Listing is ungated, so it needs no
config.
Per-doc access comes from acl grants, not config. Owner access is the seeded
Manager grant (§4); everything else is granted through the share dialog. Do
not statically grant paper-view / paper-edit / paper-manage in
production — it bypasses the share model and lets every actor read/write/manage
every doc.
The e2e suite is the deliberate exception: it runs anonymously with no seeded grants, so
frontend/playwright.config.tsgrantspaper-view+paper-editglobally (but notpaper-manage, so the share dialog stays read-only). That's a test convenience, not a production pattern.
Grants live in acl's internal tables (acl, acl_resources, acl_actions,
acl_groups, acl_audit), keyed on (resource_type="paper-doc", parent="_paper", child=<doc id>). Paper does not read or write them directly — it calls
datasette_acl.grants.grant(...) (seeding) and datasette.allowed(...)
(checks); the share dialog calls acl's JSON API for everything else.
Paper's own _datasette_paper_doc table keeps only created_by (TEXT, nullable
— the owner identity, used to seed the grant and for isOwner) and locked
(the read-only flag). The legacy visibility column and _datasette_paper_share
table were dropped (migration m004) once their data was backfilled into acl
(§10).
When a grant shrinks mid-session (a Manager removes someone, or downgrades an
Editor to Viewer, in the dialog), already-connected SSE subscribers must be
re-checked. The dialog mutates acl directly and can't reach into paper's
in-memory Instance, so it fires a bubbling share-changed CustomEvent; paper's
DocHeader listens and POSTs to a sweep endpoint:
@router.POST(r"^/-/paper/api/docs/(?P<doc_id>\d+)/sweep-subscribers$")
async def sweep_subscribers(datasette, request, doc_id: int):
await ensure_paper_view(datasette, request, doc_id) # standard 403 surface
if not await can_paper_manage(datasette, request.actor, doc_id):
raise Forbidden("paper-manage") # Manager-only
instance = get_registry(datasette)._instances.get(doc_id)
revoked = await instance.revoke_unauthorized(datasette) if instance else 0
return Response.json({"revoked": revoked})Instance.revoke_unauthorized (instance.py) re-runs paper-view per
subscriber and drops the ones that now fail:
async def revoke_unauthorized(self, datasette) -> int:
resource = PaperDocResource(self.doc_id)
revoked = 0
for q, (_client_id, actor_id) in list(self.subscribers.items()):
actor = {"id": actor_id} if actor_id else None
if not await datasette.allowed(action="paper-view", resource=resource, actor=actor):
q.put_nowait({"kind": "closed"}) # SSE-loop sentinel → clean exit
self.subscribers.pop(q, None)
revoked += 1
return revokedRecording the actor at subscribe time — the subscriber value is
(client_id, actor_id) — is what makes this sweep possible; keying by
client_id alone would lose the actor context.
Lock is the related-but-distinct case: it changes only the edit grant, so
instead of disconnecting anyone, Instance.broadcast_permissions_changed
re-checks paper-edit per subscriber and pushes a permissions-changed
event — the editor flips to read-only with no reconnect.
Migrating an existing deployment from the old (owner/share/visibility) model is a
one-shot backfill into acl grants (datasette_paper/migrations.py, the
shares_to_acl_grants step — distinct from the append-only schema migrations):
| Legacy source | Becomes |
|---|---|
_datasette_paper_doc.created_by |
a Manager grant for that actor |
_datasette_paper_share (actor_id, role='viewer'/'editor') |
a Viewer / Editor grant |
_datasette_paper_doc.visibility = 'link-view'/'link-edit' |
a Viewer/Editor grant for the general-access audience — a Principal.public(...) named in acl's own vocabulary (authenticated by default; set share-general-principal to everyone/anonymous to widen it) |
It is idempotent (a marker table short-circuits repeat runs; acl's grant
only inserts actions a principal doesn't already hold) and closed by default:
anonymous-owned (created_by NULL) and private docs gain nothing — paper never
auto-opens a doc on upgrade. It bails gracefully once the legacy column/table
have been dropped.
The backend specs are the source of truth:
tests/test_permissions.py— action wiring, ungated listing, thelockeddeny, owner/manager paths.tests/test_paper_doc_resource.py— the two-levelPaperDocResourceshape +resources_sql.tests/test_share.py— grant-backed view/edit/manage via the helpers.tests/test_data_migration.py— the one-time backfill.tests/test_lock.py— the lock deny + per-subscriberpermissions-changed.
Pattern: build a Datasette with datasette-paper-create granted in config,
sign an actor cookie, then either drive HTTP or assert datasette.allowed(...)
directly:
ds = Datasette(memory=True, config={"permissions": {"datasette-paper-create": True}})
await ds.invoke_startup()
from datasette_paper.permissions import PaperDocResource, seed_owner_manager_grant
await seed_owner_manager_grant(ds, doc_id, "alice") # owner → Manager grant
assert await ds.allowed(action="paper-edit",
resource=PaperDocResource(doc_id), actor={"id": "alice"})Per-doc access is set up by seeding acl grants, not by static config — that's what exercises the real share path.
- Doc id is the
child.PaperDocResourceis two-level: parent = fixed sentinel_paper, child = doc id. (The pre-acl model put the id inparent; listing code that readsr.parentis stale — user.child.) - Manage is an action now.
paper-manage(the Manager role), not an inlinecreated_bycheck.isOwneris a separate, UI-only signal — never gate a write on it. - The owner grant is seeded, not implied. Anonymous creates seed nothing, so an anonymous-owned doc has no grants at all.
lockedis the only paper-owned permission SQL. A child-level deny ofpaper-edit; deny-beats-allow at equal depth makes it win over every grant. Gate unlock on view + manage, never edit, or you trap the owner.permission_resources_sqlreturnsNonefor actions it doesn't own. Returning a list short-circuits other plugins' contributions.also_requiresis automatic. Don't re-check the parent action by hand.- Don't statically grant the per-doc actions in production. They flow through acl grants; static grants mask the share model. (The e2e config is the sanctioned exception.)
- Capture the actor at subscribe time for long-lived connections that may need revocation — keying by connection id alone loses the actor.
- Raw ASGI handlers use the bool form (
datasette.allowed) + a manual 403 —ensure_permissionraises after headers are sent. - acl + acl-share are hard dependencies. They're declared in
dependenciesand imported unconditionally — notry/except ImportErrorguards, noNonefallbacks. (datasette-agent stays optional: its tools hook self-registers only when installed.)
The sql_block node and the inline-value feature (source nodes +
${{source.column}} value atoms) run SQL against named Datasette databases.
Paper does not gate or execute these queries. Each is fetched client-side,
per viewer, from Datasette's native /{db}/-/query.json API with that viewer's
own cookie — so Datasette enforces their execute-sql permission on that
database (frontend/src/lib/sqlQuery.ts). Consequences:
- A viewer without
execute-sqlon the referenced database sees a leak-free "no access" state (adeniedchip / placeholder), never rows or column names. - Different readers of the same doc may therefore see a value, an error, or "no
access" depending on their own database permissions — the rendered value is
not part of the doc's shared state. Only the reference (db name, SQL,
source/column) collaborates and round-trips; results are ephemeral and re-fetched on every mount. - This deliberately sidesteps paper's per-doc ACL model: editing a doc
(
paper-edit) lets you author a query, but running it still requires the viewer's own Datasetteexecute-sql. - By-design consequence (not a hole): an editor can cause viewer-side query
execution. Because the query runs in each viewer's own browser under
their
execute-sql, a doc editor who authors asource/ inlinevalueis effectively driving every viewer's browser to run that read-only query the next time they open the doc. This is bounded the right way — the query only ever runs with the viewer's own credentials and Datasette permissions, so an editor can never read data the viewer couldn't already read themselves, and a viewer withoutexecute-sqlon the target database just gets the "no access" state. But authors should know that asourceblock is, in effect, code that executes in readers' browsers; it is intentional and gated by Datasette, not by paper.
Several endpoints turn an actor id into a display name and avatar
(via datasette-user-profiles' resolve_profile_actors, then the core
actors_from_ids hook — resolve_actor_profiles in util.py). Name and avatar
are profile data, so paper gates that resolution on user-profiles' own
profile_access action — not on paper-view/-edit/-manage, and not on
anything paper declares.
The rule (copy verbatim into any sibling plugin):
Profile resolution (name / avatar) is gated on
profile_access. An endpoint that emits a resolved name or avatar must checkdatasette.allowed("profile_access", actor=…)first and degrade to id-as-name when it's denied — it must never403on the profile gate.
Degrade, don't deny, because these ids ride along on data the actor is already
authorized to see (the rows are acl-filtered first), and the id is something the
caller usually supplied. So when profile_access is denied the endpoint returns
the raw id as the name and a null avatar — the actor learns nothing they
didn't already have. A 403 here would instead wedge the UI (mention chips stuck
on "loading", a doc list that won't render its "created by" column) for what is
only a cosmetic enrichment.
Where this is applied today:
list_docs— gates the batched creator-profile lookup onprofile_access(routes/docs.py); without it,created_by_namefalls back to the raw id andcreated_by_avatartoNone. The doc rows themselves are still returned (they were acl-filtered bypaper-view).resolve_actors(POST /-/paper/api/actors/resolve) — the route is otherwise ungated; the resolution isprofile_access-gated and degrades so each id echoes back as its own name.mention-search— required end state, see the mismatch note in §15.
The table below is the current gate for each endpoint added by the
mention / tag / profile work, cross-checked against routes/docs.py and
permissions.py. "ungated route" means the handler runs for anyone, but the
data it returns is restricted some other way (acl-filtered rows, or
degrade-on-profile_access).
| Endpoint | Method | Gate |
|---|---|---|
/-/paper/api/docs/{id}/mention-search |
GET | paper-view (only viewers may list a doc's collaborators) — see profile note below |
/-/paper/api/actors/resolve |
POST | ungated route; profile resolution gated on profile_access (degrades to id-as-name) |
/-/paper/api/docs/{id}/tags |
GET | paper-view |
/-/paper/api/docs/{id}/tags/add |
POST | paper-manage (manage, not edit) |
/-/paper/api/docs/{id}/tags/remove |
POST | paper-manage (manage, not edit) |
/-/paper/api/docs/{id}/tags/replace |
POST | paper-manage (manage, not edit) |
/-/paper/api/tags |
GET | ungated route; ACL-filtered through viewable_doc_ids (paper-view) |
/-/paper/api/tags/{tag}/refs |
GET | ungated route; ACL-filtered through viewable_doc_ids (paper-view) |
/-/paper/tag/{tag} |
GET | ungated HTML shell (the client then calls the ACL-filtered …/refs API) |
/-/paper/api/profile/{actor}/docs |
GET | ungated route; ACL-filtered through allowed_resources("paper-view") (list_docs precedent). No profile_access involvement — see §16 |
Notes:
- Tag mutations are
paper-manage, deliberately notpaper-edit. Add / remove / replace all funnel through_ensure_owner(§7), so they are Manager-only — the same gate as archive / lock / make_template. Document-level tags are sharing/organization metadata, treated like the other manage operations rather than like body edits. (Inline#tagnodes in the body are a separate namespace, authored underpaper-editlike any other content; the…/tags/{tag}/refsendpoint scans that body namespace and is read-only + ACL-filtered.) mention-searchandprofile_access— a current doc-vs-code gap. The intended end state (ticket 03) is thatmention-search, likelist_docsandresolve_actors, gates its name/avatar resolution onprofile_accessand degrades to id-as-name. As of this writing the handler is onlypaper-view- gated and callsresolve_actor_profilesunconditionally — it does not consultprofile_access. That unguarded resolution is exactly the leak ticket 03 closes; this doc records the required end state, and ticket 03 implements it. Until 03 lands, treat theprofile_accessdegrade onmention-searchas specified, not yet enforced.- Ungated-but-ACL-filtered endpoints (
/api/tags,…/refs, and the index / link-search / graph endpoints in §6) never gate the route; they enumerate only the docsallowed_resources("paper-view")returns, so a no-grant actor gets an empty result rather than a 403. This is the same "listing is not gated" pattern as the doc index (TL;DR).
GET /-/paper/api/profile/{actor}/docs backs the "Papers" section paper
registers on datasette-user-profiles' profile pages
(datasette_user_profile_sections hook). For a profile actor P viewed by
V, it lists P's active docs (created_by = P or P has an edit row
in the _datasette_paper_doc_activity rollup), intersected with the docs V
holds paper-view on, newest-activity first. The handler is
profile_docs in routes/docs.py.
Its stance is the same "listing is not gated, results are acl-filtered"
pattern as list_docs (TL;DR; §6):
- No gate on the route itself — anyone may call it, and the visible set is
built from
allowed_resources("paper-view")for the viewer (the 1000-doc precedent). A no-grant viewer short-circuits to{"docs": []}. Everything returned is a doc V can already open, so the intersection — not a route gate — is what enforces access. - Active docs only. Archived / trashed docs never appear, even to a viewer who could see them under the index's archive tab — a profile is a public-ish surface.
- No
profile_accessinvolvement. The response is doc metadata only (id, name, url,created,last_edited_at, timestamps) — no resolved names or avatars. The §14 degrade rule fires only for endpoints that emit a resolved name/avatar, so it isn't triggered here and there is nothing to resolve or degrade. (The profile page already displays P; paper doesn't re-resolve it.) - Unknown / never-seen
{actor}→200 {"docs": []}, not 404. The endpoint is not an actor-existence oracle: a valid-but-empty response is indistinguishable from "actor P has no visible docs".
GET /-/paper/api/profile/{actor}/todos (the task-assign feature) backs both
TODO surfaces: the <profile-todos> profile section and the dedicated
/-/paper/todos page. For a subject actor P viewed by V, it lists the
tasks assigned to P — a @mention inside a task item is an assignment, and it
inherits down the task subtree — across P's active docs, intersected with
the docs V holds paper-view on. The handler is profile_todos in
routes/docs.py, reading the derived _datasette_paper_task_assignment index.
Its access stance is the same clause as profile-papers (§16) — the
viewer-ACL paper-view filter is applied at query time, not at index time:
- No gate on the route itself — the visible set is
allowed_resources("paper-view")for the viewer; a no-grant viewer short-circuits to{"todos": []}. A task assigned to P in a doc V cannot see is filtered out even when V is P viewing their own list — the index rows exist, but the query never returns them (the assignment index is a derived cache, never an access-control decision). - Active docs only. Archived / trashed / template docs' tasks never appear.
- No
profile_accessinvolvement. Rows are task/doc metadata (text, doc name/url, due date, assignee ids); assignee names are resolved separately by the client through the existingactors/resolveendpoint, which owns theprofile_accessdegrade — this endpoint emits no resolved names/avatars. status=open|done|all(defaultopen; 400 otherwise), the same vocabulary and contract as the per-doc/tasksendpoint. Bucketing is the client's job (it needs the viewer's timezone), so the endpoint returns a flat ordered list.- Unknown / never-seen
{actor}→200 {"todos": []}, not 404 — not an actor-existence oracle, exactly as §16.