Authentication and Connection
Strata v0 uses one shared secret. The application sends the secret as a token when it opens a WebSocket connection. The server checks the token before it accepts the connection. Authentication is not a WebSocket frame.
Endpoint and token
Section titled “Endpoint and token”ws://<host>:8000/socket/websocket?token=<STRATA_TOKEN>- The server reads the shared secret from
STRATA_TOKEN. If the variable is unset, the server usesdev-strata-token. Use this default only for local development. - The server returns HTTP 403 for a missing or incorrect token. It compares the values in constant time.
- All connections that use the token have access to all documents and admin data. The current server is single-tenant. Client-side user checks and document ID prefixes cannot restrict a token holder's access.
For groups that must not share access, use separate Strata deployments with
separate tokens and storage directories. The session_id in welcome
identifies a socket connection, not an authenticated user or tenant.
The server does not verify JWT signatures, expiry, or tenant claims.
Putting a JWT in ?token= does not enable JWT authentication; the server
still compares the whole value with the configured shared secret.
See Security Model before you expose Strata outside a local development environment.
Connection flow
Section titled “Connection flow”- Open the WebSocket with the token in the URL.
- Receive a
welcomeframe carrying yoursession_id. - Send a
joinframe for each document that the application must open. - Receive a
snapshotfor each joined document, then a stream ofdelta,presence_state, andpresence_diffframes. - Send
pingmessages if the connection must remain active when there is no other traffic. The server answers withpong.
presence_state contains the full presence state for the document.
presence_diff contains the changes after that state.
Reconnect
Section titled “Reconnect”A disconnect removes every document join and presence entry for that
connection. The
bundled examples reconnect with strata_client:
- After the connection closes, wait 2 seconds and open a new connection.
- Call
strata_client.frames_for_resumeto get thejoinframes for every previous document. - Send the returned
joinframes. - Send
presence_setfor each document. - Merge each incoming
snapshotinto the local CRDT state.
Do not replace the local CRDT state after a reconnect. Replacement can remove local changes that the application made while it was offline.
See strata_client for the connection logic and
examples/kanban
for a working implementation.
The examples use a fixed two-second retry delay. A deployed application should use exponential backoff with jitter. It should also stop after a suitable limit or show a manual retry control.
Roadmap
Section titled “Roadmap”Issue #3 tracks JWT and
multi-tenant authentication. The proposal keeps the current ?token= URL
shape.