Document permissions¶
Each document can have an access list of the users and groups that may see it. Retrieval and the document endpoints then return only what the caller may see. Documents have no list by default, which makes them public, so nothing changes until you set one.
Access is checked in Postgres before anything is searched. Vector search, keyword search, hybrid search and reranking all work only on the documents the caller may see, so a result can't leak from a hidden document.
Who is asking¶
Pagelore doesn't sign users in. Your app does, then tells Pagelore who the request is for. There are three kinds of caller:
| Caller | Sees |
|---|---|
| A key (or no auth) that sends no identity: a trusted back end | Every document |
A request that sends user (an id and / or groups) |
Public documents, and those whose list names that user or one of their groups |
A key bound to a user (user_id on the key) |
The same, always as that user, whatever the request says |
A user's groups are the groups sent with the request, plus the stored groups the user belongs to.
Set a document's access¶
access is an object:
| Value | Who sees the document |
|---|---|
{"public": true} (or no access) |
Everyone |
{"users": ["ana@acme.com"], "groups": ["legal"]} |
Callers without an identity, Ana, and members of legal |
{"public": false} |
Only callers without an identity |
User ids are whatever your identity provider uses, such as an email or a
subject claim (up to 256 characters). Group names use letters, digits and
. _ - : @ /, so you can namespace them by source (drive:eng,
okta:legal). A list holds at most 1000 entries.
You can set it when you add the document:
# Upload: access is a JSON form field
curl -X POST http://localhost:8000/api/v1/projects/1/documents \
-F "files=@contract.pdf" -F 'access={"groups": ["legal"]}'
# Text, URL and S3 imports: access in the body (a text item's own access wins)
curl -X POST http://localhost:8000/api/v1/projects/1/documents/text \
-H "Content-Type: application/json" \
-d '{"access": {"groups": ["eng"]},
"items": [{"text": "Runbook ...", "file_name": "runbook.md"},
{"text": "Salaries ...", "file_name": "pay.md",
"access": {"users": ["cfo@acme.com"]}}]}'
A new version of a document keeps the previous version's access unless
you send access. A file reported as a duplicate or unchanged is not
stored again, so it keeps its access. Use the endpoints below to change it.
You can also change it later, with nothing re-indexed:
# One document (and every version of it)
curl -X PATCH http://localhost:8000/api/v1/projects/1/documents/42 \
-H "Content-Type: application/json" -d '{"access": {"users": ["ana@acme.com"]}}'
# Many at once, by document_id or external_id: up to 1000 per request
curl -X PUT http://localhost:8000/api/v1/projects/1/documents/access \
-H "Content-Type: application/json" \
-d '{"documents": [
{"external_id": "s3://docs/q1.pdf", "access": {"groups": ["finance"]}},
{"document_id": 7, "access": {"public": true}}]}'
The bulk endpoint reports which documents each item changed, and counts
the items that matched nothing (not_found).
Search as a user¶
Send user with a retrieval request:
curl -X POST http://localhost:8000/api/v1/projects/1/retrieve \
-H "Content-Type: application/json" \
-d '{"query": "renewal terms",
"user": {"id": "ana@acme.com", "groups": ["legal", "emea"]}}'
user.id, user.groups or both are accepted. {"groups": []} is a caller
with no groups, so it sees only public documents. POST /retrieve (several
projects) takes the same field.
The document endpoints take the identity as query parameters, user and
groups (repeat groups for each group):
The list shows only what that user may see. Getting a hidden document, or
its chunks or parents, returns 404, the same as a missing document, so
a caller can't tell that it exists. Restricted callers get access: null,
so they can't see who else may read a document. Callers without an
identity see the full list.
Keys bound to a user¶
To give an end user's app a key of its own, bind the key to the user:
curl -X POST http://localhost:8000/api/v1/auth/keys \
-H "Authorization: Bearer $ADMIN_KEY" -H "Content-Type: application/json" \
-d '{"name": "ana-desktop", "scope": "read", "user_id": "ana@acme.com"}'
Such a key:
- must have the
readscope (it can't add, change or delete documents); - always searches and lists documents as its user, with the user's stored groups;
- gets 403 if a request sends another
user.id, or any groups (its groups come only from the stored groups); - can't use the job endpoints, whose results name files.
Stored groups¶
Groups can come with each request, from your identity provider, or be stored in Pagelore. Stored groups are what keys bound to a user rely on. Managing them needs an admin key.
| Endpoint | |
|---|---|
PUT /access/groups/{name} |
Create or update a group. members replaces its users (omit it to keep them). 201 when new |
GET /access/groups |
List groups with their member counts |
GET /access/groups/{name} |
A group and its members |
DELETE /access/groups/{name} |
Delete it (204) |
POST /access/groups/{name}/members |
Add users: {"users": [...]} |
POST /access/groups/{name}/members/remove |
Remove users |
GET /access/users/{user_id}/groups |
The stored groups a user is in |
Deleting a group doesn't edit access lists that name it. Those entries then let no one in, and putting the group back restores access.
Syncing permissions from a source¶
Pagelore doesn't connect to Google Drive, Confluence or SharePoint itself. A small sync job that reads permissions from the source can keep Pagelore in step with two endpoints:
- Document permissions. For each document, send its users and groups
to
PUT /projects/{id}/documents/access, keyed by theexternal_idyou imported it with (for example the file's URL ors3://key). - Group membership. For each group in the source, send its full member
list to
PUT /access/groups/{name}. Members missing from the list are removed. Delete the groups that no longer exist.
Run it on a schedule. Changes apply to the next search, with nothing re-indexed.
Compared with Onyx¶
Onyx syncs permissions from each connector in the same two parts, with a different storage model:
| Onyx | Pagelore | |
|---|---|---|
| Access list | Prefixed strings per document (users, groups, public flag), copied into the search index | Prefixed strings per document (user:, group:) in Postgres; NULL means public |
| Who may see a document | Overlap between the user's entries and the document's | The same |
| Document sync | Each connector fetches permissions and upserts them | Your sync job calls PUT /documents/access |
| Group sync | Mark the groups stale, upsert what the source returns, delete the rest | PUT /access/groups/{name} with the full member list, DELETE for groups that are gone |
| Applying the filter | A filter in the search index, plus a post-query check for some sources | A filter in Postgres before the search. The vector DB only gets ids that are allowed, so no post-query check is needed |
| Changing access | Update the index metadata | Update one Postgres column; the vector DB is untouched |
Because the lists live in Postgres, changing access doesn't touch the vector DB, and the check works the same with every vector DB backend.
Limits¶
- Access is per document, not per chunk or page.
- Project-level limits still come from API keys. Permissions only narrow what a key's projects show.
- When a caller may see more than 1000 documents of a project but not all
of them, vector results are filtered after the vector search, as for
other document filters. Ask for a larger
top_kif results seem thin. - Evaluation (
POST /evaluate) needs awritekey and searches every document. GET /projects/{id}/index, and the retrieval warnings about documents still being indexed or stale, count every document in the project, hidden ones included. They show numbers only, never names or content.