Repository navigation
feat: recovery codes and restricted recovery sessions - #491
Merged
Merged
Conversation
… feat/recovery-codes
A user can generate single-use codes and sign in with one; the session it issues can only enroll a new factor until one is enrolled.
This was referenced Oct 22, 2026
A locked account with no passkey, or one the policy leaves with no method, continues with a pre-auth token when it holds an unused recovery code.
# Conflicts: # docs/security-posture.md # resources/coverage-badge.svg # src/controllers/authentication.ts # src/services/sessionIssuance.ts
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.
Closes #398. Depends on #482 (types 0.30.0) and #489 (auth secrets); this branch merges both, so the diff shrinks once they land.
Recovery codes
GET /recovery-codes(access):{ enabled, remaining, total, createdAt }.POST /recovery-codes(access; step-up when a set exists): ten single-use base32 codesXXXXX-XXXXX, shown once, replacing the old set.POST /recovery-codes/redeem(pre-auth, decoy-safe, OTP flow limits): spends a code with a conditional update and issues a recovery session.REFRESH_TOKEN_LOOKUP_SECRET(domain-separated); rotating that secret voids codes, documented.recovery_codes.enabledonly. Allowed in phishing-resistant-only mode.Recovery sessions (contract: fells-code/seamless-auth-types#108)
sessions.recoveryon the row (refresh keeps it),recovery: trueclaim in the access token,recovery: true+nextStep: 'enroll_passkey'in the response.verifyBearerAuthanswers403 enrollment_requiredunless the route sets the newdefineRouteoptionallowRecoverySession: passkey and TOTP enrollment, TOTP status, recovery codes,GET /users/me,/logout,/logout/all.liftRecoveryRestriction); clients should refresh to drop the claim from the token.GET /system-config/publicaddsrecoveryCodes.Left for follow-ups
recovery_codes.requireAtEnrollmentis stored but not surfaced to clients yet: the public config schema has no field for it (needs a types addition) or the SDK can read it after sign-in.recovery: trueinrequireAuth(seamless-auth-server, v0.20 adapter release) and the react prebuilt UI (seamless-auth-react#185).Checks
typecheck, lint, prettier, build, coverage (144 files, 2010 tests; statements 98.8%, branches 95.26%). Migration
20261022140000-add-recovery-codesrun up, down, up on a scratch Postgres 18.generate:apioutput committed (adapter manifest gainsPOST /recovery-codes/redeem preAuth -> session).Contract-affecting: new routes, new 403
enrollment_requiredon access routes for recovery sessions, new token claim. Adapters pick up the redeem route from the manifest; the access routes pass through by default.