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.
Before you start
Section titled “Before you start”- The CLI of this repo. Run it from this repo tells how.
- A deployed API with
organizationson. Organizations lists the keys. - A mailbox at the address of the new operator. The claim rule tells why the proof of the mailbox matters.
Do the steps in this order. Each step names what breaks when you skip it.
- Run
authtempo secret --operator --out operator-secret.txt. The file gets mode 0600, and stdout getssecretHash: <hex>.- Skip it, and no secret can call
create-admin. Only a secret or the app makes the first operator.
- Skip it, and no secret can call
- Add an entry to
operator.secrets, such as{ name: "support", secretHash: "<hex>", scopes: ["users", "audit"] }.- Without the scope
users,create-adminanswersoperator_required. - The command of step 1 prints the next step: an entry with a name, the hash, and the scopes.
- Do not set
operator.secretHashin place of the entry. That key gives the scopeskeysandsecretsonly. - The audit row names the secret by
name: 1 to 32 characters ofa-z,0-9,_, and-. - The first character of the name is a letter or a digit.
- Without the scope
- Set
operator.users: true,organizations.platformOrganization, andorganizations.platformRole.- Without
operator.users, every route of the user tools answers 404. - Without the two platform keys,
create-adminanswersnot_found.
- Without
- Deploy the config. The CLI calls the deployed API, not your local file.
- 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.
- 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
ownerand 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.
- In a new deployment it makes the platform organization with this person as
- 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.
- The proof of the mailbox verifies the address. Without it, the guard answers
- 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.
- Without a method of the second factor, the guard answers
- Run
authtempo users get <base url> <user id>. Read the columnsVERIFIED,OPERATOR, andFACTORS.VERIFIED yes,OPERATOR yes, and a method inFACTORSmean that the operator can act.- Skip the check, and you learn of a missing step only at the first act.
- Keep
operator-secret.txtas a secret, or delete it. Core keeps only its hash.- A person who holds the file can act with each scope of the entry.
How it behaves
Section titled “How it behaves”create-adminruns one transaction: the organization, the user, the member row, and one audit rowcreate_admin.- The sign-up rule does not apply. The operator, not a stranger, makes the user.
- A user who exists keeps the account.
create-adminadds the platform role to the member row, andcreatedis false. - The guard reads the session at each request. A session is fresh for
session.freshMinutesafter 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.
If it fails
Section titled “If it fails”not_found: the user tools or the platform keys are off.create-admintakes 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 inoperator.secrets.operator_required: the entry lacks the scopeusers.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.