You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e959fbe
Browse filesBrowse the repository at this point in the historyBrowse files
feat(auth): recover an account whose owner lost every passkey
An owner who loses every passkey can't get back in: adding a passkey needs a
passkey confirmation. An operator now starts a recovery (`auth-service user
recover`): it signs the account out everywhere, removes its unverified
addresses, and mails the primary verified address a link that enrolls one
passkey, once, within a day. Only an operator at the terminal sees the link.
For 15 days after the link is used, the recovery is in probation: its
passkey signs in like a social login and never confirms the session
(Credential::Probation, decided where the passkey is accepted). Every
step-up gate refuses it (account changes, owned clients, the admin API,
relying parties that ask for phr), so whoever used the link can use the
account but add no way into it.
- Undo uses any passkey but the recovery's own, needs no session and works
on a disabled account. It takes back a fixed list: the recovery's passkey,
every session and refresh grant, and every consent. Support can undo too
(`user undo-recovery`).
- Until it settles, nobody removes a passkey but the recovery's own, and
nobody is made an administrator. Administrators are never recovered.
- One recovery can be undone at a time: a start is refused during a
probation and cancels an unused link.
- `user recover --revoke [--keep]` is for an account that was in someone
else's hands: it takes back every way in but the kept passkeys and only
prints the link; every verified address is told at once.
- Triggers in the one migration (0019) hold the probation, the passkey rule
and the grant rule for every writer, older releases included.
- Authorize answers unmet_authentication_requirements instead of looping a
probation user through sign-in.
docs/security/account-recovery.md states the policy as built, as invariants
that each name their test, and support's evidence policy.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+48-8Lines changed: 48 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,7 @@ work from devices on the tailnet. Run the same command after changing code.
52
52
|`AUTH_PUBLIC_LISTENER`| Listener address; defaults to `127.0.0.1:8080`|
53
53
|`AUTH_ADMIN_LISTENER`| Optional address of the private admin API listener, e.g. `0.0.0.0:8081`. No ingress route may reach it. Without it, auth serves no admin API |
54
54
|`AUTH_KEY_ENCRYPTION_KEY`| Required env/file reference to the key that seals [signing keys](#signing-keys) in the database: 32 bytes as unpadded base64url text. A trailing newline is ignored |
55
-
|`AUTH_TOKEN_DIGEST_KEY`| Required env/file reference to the key under which refresh tokens, authorization codes and pending logins are stored as HMAC digests. Its raw bytes are the key, at least 32 of them. Passkey decoys and email verification links derive from it too |
55
+
|`AUTH_TOKEN_DIGEST_KEY`| Required env/file reference to the key under which refresh tokens, authorization codes and pending logins are stored as HMAC digests. Its raw bytes are the key, at least 32 of them. Passkey decoys, email verification links and recovery links derive from it too |
56
56
|`AUTH_TOKEN_DIGEST_KEY_ACCEPTED`| Optional env/file reference to another token digest key, accepted but never used for new digests: the next key, or the old one (see [changing the token digest key](#changing-the-token-digest-key)) |
57
57
|`AUTH_INVITE_REQUIRED`|`true` by default; set `false` to allow public registration |
58
58
|`AUTH_GITHUB_CLIENT_ID`, `AUTH_GITHUB_CLIENT_SECRET`| Both required to enable GitHub; secret is an env/file reference |
@@ -194,7 +194,8 @@ admin API (`AdminService` in `apps/auth-service/src/admin`), and so does every
194
194
setting administrators may change on another account (`AccountService` in
195
195
`apps/auth-service/src/account`). Commands need only
196
196
`AUTH_DATABASE_URL` (`invite create` also needs `AUTH_PUBLIC_BASE_URL`, to build its
197
-
link), so they work while auth is down: they are the break-glass path when the
197
+
link, and `user recover` needs it and `AUTH_TOKEN_DIGEST_KEY`, to derive its link), so
198
+
they work while auth is down: they are the break-glass path when the
198
199
dashboard or auth's frontends are unreachable. In deployed environments,
199
200
run them with `piquelctl app exec piquel-fr auth --env ENV -- auth-service …` (see
200
201
[infra/README.md](infra/README.md)).
@@ -207,6 +208,9 @@ just auth user search ali # by ID, or part of a username, name o
207
208
just auth user show alice # recorded, since it shows personal data
208
209
just auth user disable alice --reason "Spam"
209
210
just auth user enable alice
211
+
just auth user recover alice --reason "Lost every passkey"# not usable yet, see below
212
+
just auth user recover alice --reason "Phone stolen" --revoke --keep <passkey-id>
213
+
just auth user undo-recovery alice --reason "Owner confirmed by phone"
210
214
just auth session revoke <session-id># one session, as `user show` lists it
211
215
just auth session revoke-all alice # every session of the account
212
216
just auth audit --user alice --kind session_revoked
@@ -219,7 +223,8 @@ just auth account alice emails remove <email-id> --reason "Asked by email"
219
223
-`--output json` prints the admin API's body for `user search` (`UserPage`), `user
220
224
show` (`UserDetail`), `audit` (`EventPage`), `client list`, `invite list` and
221
225
`admin list`, as defined in `crates/admin-api`. It changes only as the API does.
Every reason shows in the account's history: write what was asked, never the
260
+
evidence.
261
+
- It never recovers an account while it holds administrator rights: revoke them
262
+
with `admin revoke` first (grant another administrator first if it is the
263
+
last). `admin grant` refuses while a recovery of the account can still be
264
+
undone; grant the rights again once it settles.
233
265
- Each change is recorded as a domain event with the operator: `$USER` and the host
234
-
name. Unlike the admin API, the CLI may act on administrators' accounts.
266
+
name. Unlike the admin API, the CLI may act on administrators' accounts, except
267
+
to recover one.
235
268
- Failures print their causes and exit with 1; usage errors exit with 2.
236
269
237
270
Administrators manage accounts, sessions, invitations and other administrators
@@ -436,16 +469,19 @@ authenticated:
436
469
437
470
| Claim | Values |
438
471
| --- | --- |
439
-
|`acr`|`phr` once a passkey signed in or confirmed the session: phishing-resistant multi-factor authentication ([OpenID Connect EAP ACR Values](https://openid.net/specs/openid-connect-eap-acr-values-1_0.html)). `urn:piquel:acr:social` for a session signed in with GitHub or Google only: the provider's authentication, whatever it was |
440
-
|`amr`| Every method the session used (RFC 8176): `pop`, `mfa` and `user` for a passkey, which proves possession of a key and requires user verification; `fed` for a provider sign-in. RFC 8176 registers no value for federation, so `fed` is Piquel's own |
472
+
|`acr`|`phr` once a passkey confirmed the session, which a passkey sign-in does: phishing-resistant multi-factor authentication ([OpenID Connect EAP ACR Values](https://openid.net/specs/openid-connect-eap-acr-values-1_0.html)). `urn:piquel:acr:social` for a session signed in with GitHub or Google only, the provider's authentication, whatever it was; and for one signed in with a recovered passkey until its recovery settles|
473
+
|`amr`| Every method the session used (RFC 8176): `pop`, `mfa` and `user` for a passkey, which proves possession of a key and requires user verification; `fed` for a provider sign-in. RFC 8176 registers no value for federation, so `fed` is Piquel's own. It says how, not how strongly: gate on `acr`|
441
474
|`auth_time`| The latest authentication at the session's `acr`: its last passkey confirmation, or else its sign-in |
442
475
443
476
`phr` satisfies a `urn:piquel:acr:social` requirement, not the reverse. Both values
444
477
are listed in discovery's `acr_values_supported`. An authorization request may send
445
478
`acr_values` in order of preference: the first known value becomes its target, and
446
479
unknown values are ignored. A session below the target signs in again, on a login
447
480
page offering only passkeys for `phr`; with `prompt=none` the request fails with
448
-
`login_required`. With no known value, the tokens report what the session reached.
481
+
`login_required`. If a passkey sign-in for the request still falls short, as a
482
+
recovered passkey does, the request fails with `unmet_authentication_requirements`
483
+
rather than asking again. With no known value, the tokens report what the session
484
+
reached.
449
485
450
486
Signing in again (`prompt=login`, `max_age`, a target) re-authenticates the
451
487
browser's session rather than starting another, so `sid` stays the same: a passkey
@@ -499,7 +535,11 @@ explains how to choose a requirement and handle the challenge.
499
535
identity so another account can link it; account data and credentials never move.
500
536
Settings keep listing identities of disabled providers so they can be unlinked.
501
537
- The last passkey cannot be removed. Removing a passkey/provider revokes other
502
-
central sessions. There is no recovery if every passkey is lost.
538
+
central sessions. An owner who lost every passkey is recovered with a link that
539
+
enrolls one new passkey; for 15 days after, it confirms no change, and another
540
+
passkey of the account can undo the recovery (see
541
+
[surfaces.md](docs/architecture/surfaces.md#recovering-an-account)). Until its
542
+
page ships, no page uses the link.
503
543
- Sessions last at most 30 days. Access tokens last five minutes. Refresh rotation
504
544
detects reuse and stops when its central session expires or is revoked. Ending a
505
545
session tells the clients that registered a back-channel logout URI, which end
#[error("the account is disabled; enable it before recovering it")]
85
+
RecoveryOfDisabledAccount,
86
+
/// An administrator never sees a recovery link, so only a recovery that mails
87
+
/// it to a primary verified address is theirs to start.
88
+
#[error(
89
+
"the recovery link would not be mailed (no primary verified address, or --revoke); only an operator at the terminal can recover this account, with `auth-service user recover`"
90
+
)]
91
+
RecoveryNeedsEmail,
92
+
/// Whoever used an administrator's recovery link could use its rights before
93
+
/// the owner undoes it, so an administrator is never recovered.
94
+
#[error(
95
+
"the account is an administrator: revoke its rights with `auth-service admin revoke` (grant another administrator first if it is the last), recover it, then grant them again once its owner is confirmed"
96
+
)]
97
+
RecoveryOfAdministrator,
98
+
/// A recovery of the account is in probation: support finds out who used it,
99
+
/// and undoes it first.
100
+
#[error(
101
+
"the account has a recovery in probation: find out who used it, and undo it with `auth-service user undo-recovery` before starting another"
102
+
)]
103
+
RecoveryInProbation,
104
+
/// A passkey `--keep` named is not an active passkey of the account.
105
+
#[error("passkey {0} is not an active passkey of the account")]
106
+
UnknownPasskey(PasskeyId),
107
+
/// A recovery of the account can still be undone: rights granted now would go
108
+
/// live for whoever used its link once it settles.
109
+
#[error(
110
+
"the account has a recovery that can still be undone: grant the rights once it settles, or after undoing it"
111
+
)]
112
+
GrantDuringRecovery,
113
+
/// The account has no recovery that can still be undone.
114
+
#[error("the account has no recovery that can still be undone")]
115
+
NoRecoveryToUndo,
83
116
/// Only active accounts can become administrators.
84
117
#[error("the account is disabled; enable it before granting administrator rights")]
0 commit comments