Documentation

Tokens and sessions

Lifetimes, refresh, revocation, introspection and machine-to-machine tokens.

All documentation

Lifetimes

SettingMeaningDefault
accessTokenMinutesAccess token lifetime15
refreshTokenDaysRefresh token lifetime; every refresh starts it again30
idleTimeoutMinutesA session not refreshed for this long endsnone
maximumLifetimeHoursA session ends this long after it startednone
Per application
PUT /api/v1/auth/applications/{id}/security
{ "session": { "accessTokenMinutes": 10, "idleTimeoutMinutes": 60, "maximumLifetimeHours": 720 } }

Refresh

With offline_access the token response carries a refresh token. It rotates on every use: store the new one, because the old one stops working. A replayed refresh token revokes the whole session.

Signing algorithms

Tokens are signed with RS256 by default. An application can choose ES256 for its ID tokens, and an API for its access tokens: an EC P-256 key, with shorter tokens. Both keys are in the JWKS, each with its kid and alg.

Switch an application to ES256 only when every library that verifies its tokens accepts ES256. The Ziqme SDKs do.

Step-up: acr, amr and max_age

ID and access tokens carry acr, the level the sign-in reached, and amr, the methods. phr is a passkey; urn:ziqme:acr:2 is a second factor after the first; urn:ziqme:acr:1 is one factor. Each level satisfies the ones below it, and a refreshed token says the same as the first one.

  • max_age=<seconds> on /authorize: a session that started longer ago signs in again (with prompt=none: login_required).
  • acr_values=<levels> on /authorize, in order of preference: a session that reaches none of them signs in again; a person with a second factor is asked for it.
  • If the person cannot reach the level, the tokens say what they did reach. Check acr before the sensitive action.
Ask for a second factor before a payment
/authorize?client_id=app_…&response_type=code&scope=openid&redirect_uri=…
  &code_challenge=…&code_challenge_method=S256&acr_values=urn:ziqme:acr:2&max_age=300

Revoke and inspect

POST /revoke ends a refresh token together with its session. An access token is a signed JWT, so an API that only checks the signature keeps accepting it until it expires; an API that must see revocation at once asks POST /introspect, which is for confidential applications.

Sessions

Every sign-in starts a session; its ID is the sid claim. Administrators list and end sessions per application or per person, and people end their own on the hosted account page.

Pushed authorization requests (PAR)

Post the authorization request to https://auth.ziqme.com/par with your client authentication and send the browser to /authorize with only client_id and the request_uri you get back. The request is checked at once, never passes through the browser, and the request_uri works once within 60 seconds. Switch on "Require pushed authorization requests" under Security to refuse anything else.

Push, then redirect
curl -X POST https://auth.ziqme.com/par -u app_your_client_id:YOUR_SECRET \
  -d response_type=code -d redirect_uri=https://app.example/callback -d scope="openid email" \
  -d state=STATE -d nonce=NONCE -d code_challenge=CHALLENGE -d code_challenge_method=S256
# => 201 {"request_uri":"urn:ietf:params:oauth:request_uri:…","expires_in":60}
# then: https://auth.ziqme.com/authorize?client_id=app_your_client_id&request_uri=urn%3Aietf%3A…

Signed request objects (JAR)

Send the authorization parameters as a JWT in the request parameter, signed with a key registered under Security, Client authentication: iss is your client ID, aud the issuer, exp at most an hour ahead. Only the parameters inside it count.

Private key instead of a secret (private_key_jwt)

A confidential application can authenticate with a key pair instead of its client secret. Register its public keys under Security, Client authentication, as a JWKS URI or a pasted key set (RSA 2048+ or P-256, public only). From then on the secret is refused: sign a fresh assertion for each request and send it as client_assertion.

ClaimValue
iss, subYour client ID
audhttps://auth.ziqme.com or the endpoint you call, such as https://auth.ziqme.com/token
expAt most 10 minutes ahead
jtiUnique; each assertion works once
alg (header)RS256, PS256 or ES256
Client credentials with an assertion (Node, jose)
import { SignJWT, importPKCS8 } from 'jose'

const key = await importPKCS8(process.env.CLIENT_PRIVATE_KEY, 'RS256')
const assertion = await new SignJWT({})
  .setProtectedHeader({ alg: 'RS256', kid: 'my-key-1' })
  .setIssuer('app_your_client_id').setSubject('app_your_client_id')
  .setAudience('https://auth.ziqme.com/token').setJti(crypto.randomUUID()).setIssuedAt().setExpirationTime('2m')
  .sign(key)

await fetch('https://auth.ziqme.com/token', {
  method: 'POST',
  body: new URLSearchParams({
    grant_type: 'client_credentials',
    client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
    client_assertion: assertion,
  }),
})

Sender-constrained tokens (DPoP)

Send a DPoP proof (RFC 9449) with a token request and the access token is bound to your key: cnf.jkt names it and token_type is DPoP. A public client's refresh token is bound too, so a copied refresh token is useless. Switch on "Require DPoP-bound tokens" under Security to refuse token requests without a proof.

ProofValue
typ, alg, jwk (header)dpop+jwt; RS256, PS256 or ES256; your public key
htm, htuThe request method and URL, such as POST and https://auth.ziqme.com/token
iat, jtiNow, and unique: each proof works once and for 5 minutes
athAt UserInfo or your API: base64url(SHA-256(access token))

At UserInfo send Authorization: DPoP <token> with a fresh proof. A bound token sent as Bearer is refused. Introspection returns token_type DPoP and cnf for a bound token.

Machine-to-machine

A confidential application can get a token for itself with grant_type=client_credentials, once the grant is switched on in its security settings. Name another application of the same workspace as audience and that application's client ID becomes aud.

Client credentials
curl -X POST https://auth.ziqme.com/token \
  -u app_your_client_id:YOUR_SECRET \
  -d grant_type=client_credentials \
  -d audience=app_the_api_client_id

Custom claims

An administrator keeps publicMetadata and privateMetadata on each person. Neither reaches a token by itself: each application maps the values it wants into claims of its own tokens, up to 20 mappings. Reserved claims such as sub, roles and email cannot be replaced.