Skip to content

feat(auth): recovery follow-ups: no admin grant mid-recovery, trusted mail target, used-only refusal - #190

Merged
PiquelChips merged 2 commits into
feat/admin-recoveryfrom
feat/recovery-follow-ups
Oct 24, 2026
Merged

PiquelChips merged 2 commits into
feat/admin-recoveryfrom
feat/recovery-follow-ups

Conversation

@PiquelChips

@PiquelChips PiquelChips commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Three rules the user approved after #180's fourth review round, kept out of #180 so it can merge as it is. Stacked on #180; it retargets to main once #180 merges.

How

  • No administrator grant while a recovery can be undone. Whoever holds or used the link could use the rights, and an undo wouldn't take them back.
    • AdminService::grant_administrator takes a WhileUndoable and refuses under the account lock (GrantDuringRecovery).
    • The admin API, and later the dashboard, always pass Refuse. The CLI's admin grant --despite-undoable passes Proceed, once support has confirmed the owner.
    • This enforces feat(auth): recover an account whose owner lost every passkey #180's "grant them again once the owner is confirmed".
  • A forced second recovery mails the trusted primary. A new recovery records the current primary, or, while another recovery can be undone, the one the oldest of them recorded (AdminService::trusted_primary). Whoever used that earlier recovery can't have chosen it.
    • The email channel mails a recovery's link to the address it recorded, not to the account's current primary.
    • With none recorded, or if that address is gone or unverified, the link is mailed nowhere and only printed to the operator; an administrator gets RecoveryNeedsEmail.
    • The recovery's undo restores that same address.
  • Only a used recovery blocks a new one. An unused link let nobody in, so a new recovery just replaces it without --despite-undoable. The CLI's pre-check matches.
  • Docs:
    • docs/security/account-recovery.md: R3, R6, L4, T2 and S4 updated, a new A3, and the harassment row.
    • The evidence policy now says when admin grant --despite-undoable may be used.
    • The README's administration section and surfaces.md match.

Note on the literal rule (2): an unused link that recorded no address also counts. So a recovery started within 24 hours of an unused, address-less one is only printed, not mailed. A narrower rule would trust only used recoveries' recorded addresses. That's a decision for the user, so it isn't built.

Tests

  • admin::tests::no_grant_while_a_recovery_can_be_undone: the admin API answers 409, the CLI refuses without the flag, and grants with it.
  • a_forced_recovery_mails_only_the_primary_from_before:
    • after support was talked into moving the primary, the forced recovery's link goes to the earlier recorded address, never the new one, and its undo restores it;
    • when nothing was recorded, the link is only printed.
  • administrators_never_see_the_link: an unused link is replaced without the flag. support_undoes_a_hijacked_recovery still refuses while a used recovery can be undone.
  • Mutation-checked:
    • the grant check;
    • the admin API passing Proceed;
    • recording the current primary instead of the trusted one;
    • the email channel mailing nothing;
    • an unused link blocking.
  • Other checks: just db test (205), just test, just lint, just doc, just web check.

Review

GPT 6.1 Sol reviewed ecf4b8d and found no implementation problem. Its two P2 policy gaps are fixed in f7b2e39:

  • Support now undoes every unused link before admin grant --despite-undoable, and reviews every undoable recovery.
  • The evidence policy explains that while an earlier recovery can be undone, the next link goes to the address it recorded, so changing the primary redirects nothing until that recovery is undone.

Also in f7b2e39:

  • the "start-time primary" wording is corrected;
  • new tests check that a forced recovery's undo restores the recorded address, and that a grant goes through once support undid the recovery.

The comment in 0019_account_recoveries.sql is left as it is. That migration is #180's, and editing it here would change its checksum.

Part of #85.

Note

Written by Claude Opus 5.5 in Claude Code and reviewed by GPT 6.1 Sol (via T3 Code)

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a47694fa-b28a-4c94-8c99-f8d76e903a59

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

PiquelChips and others added 2 commits October 24, 2026 22:10
- Nobody is made an administrator while a recovery of the account can
  still be undone: the admin API refuses, and the CLI grants only with
  `admin grant --despite-undoable`, once support has confirmed the owner.
- A recovery records, and mails its link to, the trusted primary
  address: the current one, or, while another recovery can be undone, the
  one the oldest of them recorded. With none, the link is only printed.
- Only a used recovery blocks starting another; a new recovery simply
  replaces an unused link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Support undoes every unused link before granting an administrator's
rights back, since confirming the owner says nothing about who holds a
link nobody used, and reviews every undoable recovery. While an earlier
recovery can be undone, the next link goes to the address it recorded, so
changing the primary redirects nothing until it is undone. Tests: a forced
recovery's undo restores that address, and a grant goes through once
support undid the recovery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PiquelChips
PiquelChips force-pushed the feat/recovery-follow-ups branch from f7b2e39 to c81fa9e Compare October 24, 2026 20:11
@PiquelChips PiquelChips self-assigned this Oct 24, 2026
@PiquelChips PiquelChips added enhancement New feature or request security Anything security related apps/auth-service Origin Auth at auth.sourceorigin.dev, its settings and developer console, and the operator CLI labels Oct 24, 2026
@PiquelChips PiquelChips added this to the 0.1 milestone Oct 24, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in sourceorigin.dev Oct 24, 2026
@PiquelChips PiquelChips moved this from Needs Triage to In Progress in sourceorigin.dev Oct 24, 2026
@PiquelChips
PiquelChips merged commit 877efcd into feat/admin-recovery Oct 24, 2026
11 checks passed
@PiquelChips
PiquelChips deleted the feat/recovery-follow-ups branch October 24, 2026 20:24
@github-project-automation github-project-automation Bot moved this from In Progress to Done in sourceorigin.dev Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apps/auth-service Origin Auth at auth.sourceorigin.dev, its settings and developer console, and the operator CLI enhancement New feature or request security Anything security related

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant