Skip to content

Request paths

What happens, step by step, in a sign-in, a token refresh, a machine token request and a Data API query.

Applies to EngineCloud
View as Markdown
On this page
  1. A password sign-in
  2. A token refresh
  3. A machine token with a key pair and DPoP
  4. 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

  1. POST /auth/v1/token?grant_type=password with the publishable key.
  2. The rate limit for this IP and e-mail is checked and counted in sypnia_auth.rate_limits (one statement).
  3. The user is read; the password is checked with argon2id (about 100 ms, on purpose).
  4. A session row and a refresh token row (only its SHA-256) are written; the session policy decides not_after.
  5. The access token is signed with the project’s Ed25519 key (decrypted once per process and kept in memory).
  6. An audit row is written. Answer: the session JSON.

Typical time: 120–250 ms, most of it the password hash.

A token refresh

  1. POST /auth/v1/token?grant_type=refresh_token.
  2. 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.
  3. 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

  1. POST /auth/v1/oauth/token with client_assertion and a DPoP header.
  2. The client is read; the assertion’s signature is checked against the client’s registered public keys; iss, sub, aud and exp are checked; its jti is inserted in sypnia_auth.assertion_jti (a duplicate fails).
  3. The DPoP proof is checked: signature, method, address, age, unused jti.
  4. Scopes and resource are intersected with what the client may have; the access token is signed with cnf.jkt set to the proof key’s thumbprint.

A Data API query

  1. GET /rest/v1/orders?select=id,total&status=eq.paid with a publishable key and a user’s access token.
  2. 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.
  3. The URL is parsed and checked against the schema cache; unknown tables or columns fail here with a clear error.
  4. One transaction: set local role, the claims into request.jwt.claims, one SQL statement that returns JSON directly from Postgres, commit.
  5. The JSON is streamed back.

Typical time: 5–20 ms on top of what the query itself costs in your database.

  1. A password sign-in
  2. A token refresh
  3. A machine token with a key pair and DPoP
  4. A Data API query

    Search pages, sections and terms