feat(sync): paginate Android sync with change tokens
This commit is contained in:
1 parent
0ff94f9b10
commit
97c237be80
76 files changed
+3401
-851
No files matched your search
+25
-15
@@ -87,9 +87,11 @@ accounts can exist, with `user`/`admin`/`superadmin` roles managed via `/api/aut
|
||||
AuthGuard integration has three states: `AUTHGUARD_URL` set (used immediately); unset with
|
||||
`AUTH_DISABLED` unset/false (the default -- "pending": auth stays fully enabled/gated, waiting
|
||||
for ProjectConfigurator's push, failing closed on auth calls until then); or `AUTH_DISABLED=true`
|
||||
(authentication fully off -- no login screen, nothing gated). Only set `AUTH_DISABLED=true` for
|
||||
local development or a deployment you are certain does not need access control. API tokens are
|
||||
unrelated to AuthGuard (see below), hashed at rest, and shown only when generated.
|
||||
(the browser-session gate is off). List access still requires membership. In this mode requests
|
||||
use placeholder identity 0, which has no list memberships, so the dashboard data is empty and
|
||||
sync API tokens for identity 0 are rejected. Use it only for local development of the auth shell,
|
||||
not for a working data deployment. API tokens are unrelated to AuthGuard (see below), hashed at
|
||||
rest, and shown only when generated.
|
||||
|
||||
### Data
|
||||
|
||||
@@ -106,6 +108,14 @@ unrelated to AuthGuard (see below), hashed at rest, and shown only when generate
|
||||
- `POST /api/sync`
|
||||
- `GET /api/notifications/poll?since=<timestamp-ms>`
|
||||
|
||||
The list, field, item and item-value collection GETs accept `limit` (default 200, maximum 500)
|
||||
and an opaque `cursor`. They return `{ "items": [...], "nextCursor": "...", "hasMore": true }`;
|
||||
continue with `nextCursor` while `hasMore` is true. The final page has an empty `nextCursor`.
|
||||
`POST /api/sync` requires `lastSyncToken` (use `0` for the first sync) and returns at most 500
|
||||
changes with `nextSyncToken` and `hasMore`. Clients must request each page until `hasMore` is
|
||||
false. Older sync clients without `lastSyncToken` receive HTTP 400 and must be updated with the
|
||||
server.
|
||||
|
||||
### Dashboard and health
|
||||
|
||||
- `GET /health` is public.
|
||||
@@ -135,9 +145,9 @@ unrelated to AuthGuard (see below), hashed at rest, and shown only when generate
|
||||
CollabTable authenticates against, default unset (pending). Leaving it unset does not disable
|
||||
authentication -- it leaves the service "pending" until ProjectConfigurator pushes a URL,
|
||||
failing closed on auth calls until then. Use `AUTH_DISABLED` to actually turn auth off.
|
||||
- `AUTH_DISABLED` — set `true` to disable authentication entirely (no login screen, nothing
|
||||
gated, every request treated as authenticated), default `false`. For local development or a
|
||||
standalone deployment with no AuthGuard integration at all.
|
||||
- `AUTH_DISABLED` — set `true` to disable browser-session gates, default `false`. List access is
|
||||
still membership-scoped; placeholder identity 0 has no memberships and its sync tokens are
|
||||
rejected. Use only for local auth-shell development, not a working data deployment.
|
||||
- `DB_INIT_RETRY_INTERVAL_MS` — startup retry delay, default `5000`
|
||||
- `DB_INIT_RETRY_MAX_ATTEMPTS` — maximum startup attempts, `0` retries forever
|
||||
- `SYNC_MAX_FUTURE_SKEW_MS` — allowed client timestamp skew, default `0`
|
||||
@@ -169,17 +179,17 @@ attribute. `Strict-Transport-Security` is not set here; set it at the TLS proxy.
|
||||
|
||||
## Access model
|
||||
|
||||
There is one shared data set. Lists, fields, items and values have no owner and no per-list
|
||||
roles: any valid sync token can read, change and delete all of them, and any signed-in dashboard
|
||||
user can see all of them. Tokens are per account only so that each can be regenerated on its own.
|
||||
Deleting an item, field or list removes its values for good, while the rows themselves are soft
|
||||
deleted. Per-list access would need a membership table checked in every handler; that has not
|
||||
been decided.
|
||||
List, field, item and value reads and writes are scoped to `list_memberships`. On migration,
|
||||
every current API-token user is granted access to every existing list because the old schema did
|
||||
not store owners. Lists created afterward are owned only by their creator. There is currently no
|
||||
API for owners to add or remove members, so a newly created list is private to its creator's
|
||||
account and devices. Deleting an item, field or list still removes its values permanently, while
|
||||
the parent rows remain soft-deleted.
|
||||
|
||||
When login is off (`AUTH_DISABLED=true`, or the login-required switch turned off in
|
||||
ProjectConfigurator), the dashboard data and user management need no session. Sync tokens are a
|
||||
separate matter: a caller without a session can only mint a token for the placeholder identity,
|
||||
and the sync API refuses that identity.
|
||||
ProjectConfigurator), browser-session gates are bypassed. Data remains membership-scoped; the
|
||||
placeholder identity 0 has no memberships, so `/web/data` contains no lists. A caller without a
|
||||
session can only mint a token for that placeholder identity, and the sync API refuses it.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
Reference in new issue
Block a user