Repository navigation
feat(cli): rename the deploy operator and declare a break-glass administrator - #3406
Merged
Merged
Conversation
…istrator A managed deployment signs in as its operator with the password alone on every run, and the operator's user id anchors the bootstrap journal, the managed native clients, operator-owned skills and API keys. Enforcing the two-factor policy therefore needs that account to become a machine-held one, and a second administrator to exist for when it is unavailable. - identity.migrateEmailFrom renames the retained operator in place: the CLI reads the current address backend-locally, signs in with it, journals the change, renames through Better Auth's internal adapter guarded by the previous address, ends every session of the account, signs in again and re-attests the new address. A replay completes without a second rename. - identity.breakGlass declares one administrator whose password reaches the deployment only as a Better Auth hash. The backend creates the account or sets it back to exactly that credential (ending its sessions when it changes), a journal binds the address to one account id, and membership converges to admin through the native member doors without touching an owner. The deployment never signs in as it. - tale auth hash-password prints that hash from stdin or a hidden prompt and refuses a password that fails the platform's default policy. - A password sign-in answered with a two-factor challenge or the enrolment wall now names which one stopped the unattended deploy.
…hash-password The self-hosted CLI guide (EN/DE/FR) and the CLI readme describe identity.migrateEmailFrom, identity.breakGlass, tale auth hash-password and why a managed deploy operator holds a passkey and never an authenticator app under an enforced two-factor policy. The manual automation reference names the suites that own the behaviour and what they do not prove.
…n one Review findings on the break-glass administrator and the operator rename: - The role door sits behind the organization-scope check like every member route, so the membership call now names `orgId`; without it the backend answered 400 and a non-admin membership could never converge. The test doubles now refuse a role call without it. - A credential write is journaled (`credentialPending`) before it happens and cleared only after the account's sessions are proven ended, so a run that dies between the write and the sweep still ends the old sessions on replay. - An unbound account at the address is adopted only when it is this deployment's own interrupted creation: a pending journal and no provider account at all. Any other account is refused instead of being made an administrator with its existing way in intact. - The platform's adapter runs without transactions, so the account ID is bound in the journal right after the user row exists, before its credential; the transaction wrapper is gone. - Renaming an operator that holds a single sign-on link is refused before any write: the link belongs to the person who signed in with it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A managed deployment (
tale deploy --bundle) signs in as itsidentityoperator on every run, with the password alone. Two consequences:two_factor_policywithout breaking its own deploys. A password sign-in of a TOTP-enabled operator is answered with a challenge, and an operator with neither factor is held at the enrolment wall once its grace period ends. The CLI stopped at both with one generic message.operatorUserId), operator-owned skills (skillOwner: "operator", which has no ownership transfer) and API keys. So a new account cannot take over deploys of an existing deployment.The way out keeps the operator account but gives it a machine address. It holds a passkey, which satisfies the policy without challenging the password sign-in. People sign in with their own accounts and choose either factor. A separate break-glass administrator covers the case where the operator is unavailable.
Interface
Deployment spec
identity:migrateEmailFrom(literal address): the retained operator's previous sign-in address. Requiresbootstrap: "fresh"and must differ fromidentity.email.breakGlass: { email, passwordHash }:emailis a literal or a required env reference, distinct from the operator's current and previous address;passwordHashis a required env reference to a Better Auth 1.6 hash (<32 hex>:<128 hex>).The host resolves both into private provisioning stdin only; the bundle carries the variable names.
tale auth hash-passwordprints that hash from stdin (or a hidden prompt with confirmation). It refuses a password that fails the platform's default password policy and prints nothing but the hash.Operator address migration
migratingEmailFrominbootstrap.json, then rename the account through Better Auth's internal adapter. The write is scoped withrunWithAdapter, so only this exact update passes, guarded byemail = previous; a concurrent change is refused, not overwritten.migrateEmailFromdeclared afterwards is harmless.Break-glass administrator
After the managed organization is selected, the backend converges on the declaration:
break-glass.jsonbinds its id as soon as the user row exists, before its singlecredentialaccount holding the declared hash is linked. The platform's adapter runs without transactions, so this binding is what makes a partial creation resumable.credentialPendingbeforehand and cleared only after the account's sessions are proven ended. A run that dies between the write and the sweep still ends the old sessions on replay./api/app/members?orgId=…,…/:memberId/role?orgId=…): add asadmin, or setadmin. Anowneris never touched.Refusals (new)
The deploy operator has TOTP enabled; a managed deploy signs in with its password alone, so the operator must hold a passkey and no TOTP.The deploy operator has no second factor and its two-factor enrolment grace period has ended; register a passkey for it.Tests
operator-address.test.tsandbreak-glass.test.tsdrive real Better Auth 1.6.30 (internal adapter, adapter scoping, transactions) over its memory adapter.identity.test.ts,email-attestation.test.ts,apply.test.tsandfresh-inputs.test.tscover admission, journaling, replay, receipts and private-input custody.password-hash.test.ts/hash-password.test.tscover the helper, andtests/hash-password.test.tsruns it as a subprocess against source and the compiled binary (verifyPasswordaccepts its output).Local results (macOS arm64):
tools/cli:tsc --noEmitclean,oxlintclean,bun test1212 pass / 19 skip / 1 fail. The failure isruntime-configuration.test.ts › the actual fixed reader … refuses … alternate mounts; it fails identically with this change stashed, so it's pre-existing and macOS-specific.build:mac+check:bundleOK; the compiledauth hash-passwordsubprocess suite 8/8.services/docsvitest 34 files / 166 tests;bun run lint:manualOK;oxfmt --checkclean.Known limits
Review
An independent adversarial read found four defects, fixed in
fix(cli): bind the break-glass account first and never adopt a foreign one:orgId;It also found the SSO-link case (now refused).
Docs
The CLI readme,
docs/{en,de,fr}/self-hosted/install/cli-install.md(new anchored subsections plus theauthcommand list) and the manual automation reference.