Skip to content

The first operator

For: an operator who sets up a new deployment and needs its first platform operator.

What it does: this runbook makes an operator secret, creates the first platform operator with authtempo create-admin, and checks that the operator can act.

Do the steps in this order. Each step names what breaks when you skip it.

  1. Run authtempo secret --operator --out operator-secret.txt. The file gets mode 0600, and stdout gets secretHash: <hex>.
    • Skip it, and no secret can call create-admin. Only a secret or the app makes the first operator.
  2. Add an entry to operator.secrets, such as { name: "support", secretHash: "<hex>", scopes: ["users", "audit"] }.
    • Without the scope users, create-admin answers operator_required.
    • The command of step 1 prints the next step: an entry with a name, the hash, and the scopes.
    • Do not set operator.secretHash in place of the entry. That key gives the scopes keys and secrets only.
    • The audit row names the secret by name: 1 to 32 characters of a-z, 0-9, _, and -.
    • The first character of the name is a letter or a digit.
  3. Set operator.users: true, organizations.platformOrganization, and organizations.platformRole.
    • Without operator.users, every route of the user tools answers 404.
    • Without the two platform keys, create-admin answers not_found.
  4. Deploy the config. The CLI calls the deployed API, not your local file.
  5. Put the secret in AUTHTEMPO_OPERATOR_SECRET, or pass --token-file operator-secret.txt.
    • Without a secret, the command stops before it sends a request.
  6. Run authtempo create-admin <base url> --email <address> --reason "first operator" --yes. It prints the user id.
    • In a new deployment it makes the platform organization with this person as owner and the platform role.
    • It makes the user when no user has the address, with no password and an unverified address.
    • Without --yes, a run with no terminal stops and changes nothing.
  7. Ask the person to sign in with a magic link to the address. An email code works too, when it is on.
    • The proof of the mailbox verifies the address. Without it, the guard answers operator_required.
    • The proof claims the address. A stranger who signed up at it first loses each credential.
    • Sign in after create-admin. A session from before the grant holds no operator power.
  8. Ask the person to turn a second factor on, from the account settings of your app.
    • Without a method of the second factor, the guard answers operator_required.
  9. Run authtempo users get <base url> <user id>. Read the columns VERIFIED, OPERATOR, and FACTORS.
    • VERIFIED yes, OPERATOR yes, and a method in FACTORS mean that the operator can act.
    • Skip the check, and you learn of a missing step only at the first act.
  10. Keep operator-secret.txt as a secret, or delete it. Core keeps only its hash.
    • A person who holds the file can act with each scope of the entry.
  • create-admin runs one transaction: the organization, the user, the member row, and one audit row create_admin.
  • The sign-up rule does not apply. The operator, not a stranger, makes the user.
  • A user who exists keeps the account. create-admin adds the platform role to the member row, and created is false.
  • The guard reads the session at each request. A session is fresh for session.freshMinutes after the sign-in, 1440 by default. After that, the operator signs in again or re-authenticates.
  • The new operator has no power before the proof of the mailbox and a second factor.
  • not_found: the user tools or the platform keys are off. create-admin takes an address and makes a missing user, so a missing user is no cause there. At step 9, no user has the id.
  • unauthorized: the secret is wrong, or its hash is not in operator.secrets.
  • operator_required: the entry lacks the scope users.
  • rate_limited: the 600 calls of this hour from this IP, or of this secret, are spent.
  • invalid_body: the address, the name, or the reason breaks its rule.
  • account_banned: a user with the address exists, and is banned. Unban the user first.
  • member_limit: the platform organization holds its most members.
  • conflict: another change ran at the same time. Run the command again.
  • hook_refused: a before hook of your app refused the act.
  • hook_failed: a before hook of your app threw another error.