Request paths
What happens, step by step, in a sign-in, a token refresh, a machine token request and a Data API query.
Every request starts the same way: the address’s host names the project (<ref>.data.sypnia.com, or a self-hosted engine’s configured host), the registry gives that project’s database, and a pooled connection to it is taken.
A password sign-in
POST /auth/v1/token?grant_type=passwordwith the publishable key.- The rate limit for this IP and e-mail is checked and counted in
sypnia_auth.rate_limits(one statement). - The user is read; the password is checked with argon2id (about 100 ms, on purpose).
- A session row and a refresh token row (only its SHA-256) are written; the session policy decides
not_after. - The access token is signed with the project’s Ed25519 key (decrypted once per process and kept in memory).
- An audit row is written. Answer: the session JSON.
Typical time: 120–250 ms, most of it the password hash.
A token refresh
POST /auth/v1/token?grant_type=refresh_token.- The token’s hash is looked up. If it was already rotated: within the reuse window (10 s), the newest token of the chain is returned again; after it, the whole session is revoked and the call fails.
- Otherwise a new refresh token row is written with the old one as parent, the old one is marked revoked, and a new access token is signed — all in one transaction.
Typical time: 15–30 ms.
A machine token with a key pair and DPoP
POST /auth/v1/oauth/tokenwithclient_assertionand aDPoPheader.- The client is read; the assertion’s signature is checked against the client’s registered public keys;
iss,sub,audandexpare checked; itsjtiis inserted insypnia_auth.assertion_jti(a duplicate fails). - The DPoP proof is checked: signature, method, address, age, unused
jti. - Scopes and resource are intersected with what the client may have; the access token is signed with
cnf.jktset to the proof key’s thumbprint.
A Data API query
GET /rest/v1/orders?select=id,total&status=eq.paidwith a publishable key and a user’s access token.- The auth context is built: the key says which project; the token’s signature is checked with the project’s public keys (cached); if the token is DPoP-bound, the proof is checked; the result is a principal and a database role.
- The URL is parsed and checked against the schema cache; unknown tables or columns fail here with a clear error.
- One transaction:
set local role, the claims intorequest.jwt.claims, one SQL statement that returns JSON directly from Postgres, commit. - The JSON is streamed back.
Typical time: 5–20 ms on top of what the query itself costs in your database.