Skip to content

authtempo keys rotate

For: an operator who rotates the signing key of the JWTs on a schedule, or after a leak.

What it does: this page lists the flags of authtempo keys rotate, the operator route that it calls, and the timer of core.

The @authtempo packages are on npm. Add the CLI to your app with pnpm add -D @authtempo/cli, and run each command as pnpm exec authtempo ….

Terminal window
authtempo keys rotate https://api.example.com --yes
Flag What it does
<base url> The origin of the API, with no path.
--token-env <NAME> The variable of the operator secret. The default is AUTHTEMPO_OPERATOR_SECRET. Secrets gives the rule.
--token-file <path> The file of the operator secret. A dash reads stdin, and then the command needs --yes. Secrets gives the rule.
--base-path <path> The basePath of the deployment. The default is /auth.
--timeout <seconds> The time limit of each request, from 1 to 120. The default is 10.
--yes Rotates with no question. A run with no terminal needs it.
--no-input Asks no question. Without --yes, the command stops.
--json Prints { kid, exit, stopped }. exit: the exit code of the run. stopped: the reason of a stop or a usage error, or null.
-h, --help Prints the complete help. The command ignores every other argument.
Exit code What it means
0 The deployment made a new key. The command prints its kid.
2 A usage error, or a stop: no answer, the route is off, the deployment refused the secret, or the secret has no keys scope.

The command prints kid: <kid> only. It reads the key set before and after the call, and warns when a cache still serves the old set.

Terminal window
openssl rand -base64 32
printf '%s' "$AUTHTEMPO_OPERATOR_SECRET" | shasum -a 256
  • The first command makes a secret of 32 random bytes. The second prints its SHA-256 for operator.secretHash.
  • Core stores the hash, never the secret. It hashes the presented secret and compares the two digests in constant time.
  • The secret is not an API token. No user owns it, and no session reaches the route.
Field Value
Route POST /operator/keys/rotate
Header Authorization: Operator <secret>
Answer { kid }. The old key verifies for 24 hours and signs nothing.
Limit The key operator:ip:<ip>, a window of 1 hour, and 5 calls, right or wrong secret. Limits lists every limit.
Errors unauthorized, rate_limited
  • jwtMint.rotateEvery is a number of days from 1 to 365. It is off by default.
  • The first signature with a key of that age makes a new key. A read of the key set never rotates.
  • Two signatures at once make one new key. The old key verifies for 24 hours.