Menu
Authentication and sessions
Public operations, session tokens, API keys and OAuth tokens; signing in without a password; strong authentication.
Each operation says who may call it, in x-weird-auth:
public: anyone, with no credential (signing in, the device login's first steps, the health check);session: a person signed in, with a session access token;key: an API key holding the permission the operation names inx-weird-scope, or a session;oauth: an access token an OAuth client obtained.
Every credential is sent the same way: Authorization: Bearer <token>.
| Scheme | How it is sent | What it is |
|---|---|---|
apiKey | Authorization: Bearer … | an API key token (weird_...), authenticating as its account within its granted scopes |
oauthAccessToken | Authorization: Bearer … (JWT) | an OAuth access token obtained from /oauth/token by a registered client |
refreshCookie | Authorization: undefined … | a page's refresh cookie (HttpOnly, Secure, SameSite=Strict, Path=/auth, 30 days), set by a sign-in made with X-Weird-Session: cookie, read by POST /auth/refresh alone (with that header, from the application's own origin), rotated at each refresh and cleared by a sign-out |
sessionToken | Authorization: Bearer … (JWT) | a session access token (the auth pair's access_token) |
x-weird-auth | Operations |
|---|---|
public — none: anyone may call it | 25 |
session — a session access token (a signed-in person, not an API key) | 9 |
key — an API key holding the permission below, or a session | 237 |
oauth — an OAuth access token | 1 |
Sessions#
There are no passwords. A person signs in with a code emailed to them:
POST /auth/login/startwith the email address emails a sign-in code of eight letters and digits, shownXXXX-XXXX, and answers a flowtoken(the answer is the same whether or not the address has an account);POST /auth/login/verifywith thattoken, the emailedcode(in any case, the dash optional) and, for an account with an authenticator, its current code (totp_code) or an unused backup code, answers the auth pair:access_token,refresh_tokenand theuser. Too many wrong codes from one network in an hour answer 429rate-limitedfor that network only: try again later or from another network.
The access token is valid for 7 days. The refresh token is valid for 30 days and can be used only once: POST /auth/refresh answers a new pair for the same session. Sending a refresh token that was already used ends the whole session, and the person must sign in again.
A terminal or another device without a browser signs in with the device login: POST /auth/device/start answers a code the person approves while signed in elsewhere (weird login --device does this). Sessions are listed and ended with the session operations; weird sessions and weird logout are the CLI's.
API keys#
An API key (weird_...) acts as its account within the permissions it was created with. It is made by a signed-in person, shown once, and cannot be changed: see API keys and permissions.
Strong authentication#
Some operations need more than a credential (x-weird-strong-auth):
none: nothing more;recent-step-up: a caller signed in with a session needs an authenticator enrolled on the account (403enrolment-requireduntil one is) and a recent proof of it: the session was stepped up in the last 15 minutes (POST /auth/step-up, or a sign-in that carried the second factor), or the request body carriestotp_code(a current authenticator code) orbackup_code(an unused backup code). Without either the answer is 403step-up-required: step up, then retry. A wrong or used code is 422invalid-totp, and too many wrong codes are 429rate-limitedfor a while. An API key is not asked for a second factor;code-in-request: the code must be in the request body itself, from a session and an API key alike (a recent step-up is not enough).x-weird-code-in-request-whennames the case when an operation asks for a code only sometimes.
The operations that spend credits or cannot be undone are the ones that need it; each operation's page says which.