Repository navigation
feat(auth): remove the signed-in user's MFA recovery codes - #611
Merged
Merged
Conversation
Tr00d
force-pushed
the
feat/auth.mfa_recovery_codes.unenroll
branch
from
October 30, 2026 13:44
ba27c60 to
9028dd9
Compare
Tr00d
marked this pull request as ready for review
October 30, 2026 13:47
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.
Summary
A signed-in user at
aal2can remove their MFA recovery codes factor, which invalidates every remaining code.Capability:
auth.mfa_recovery_codes.unenroll(MFA Recovery Codes Unenroll). There is no capability spec for it; the contract is the auth OpenAPIDELETE /factors/recovery-codes.Public API
No new types.
Behavior
Operation:
DELETE /factors/recovery-codeswith the session's access token asAuthorization: Bearer, plus the API key header.aal2session.Checks before the wire: an offline client throws
GotrueException(ReasonOffline). No session, or a session without an access token, throwsGotrueException(ReasonNoSessionFound). Neither sends a request.Output: the method completes on 200. The server's
{ id }body (the removed factor id) is not surfaced.Failures: each throws
GotrueExceptioncarrying the server'sErrorCode:insufficient_aalwhen the session is not ataal2;mfa_factor_not_foundwhen the user has no recovery codes;no_authorizationfor an anonymous user;bad_jwtfor an expired token.Reasonfollows the existingerror_codeand status mapping. NoFailureHint.Reasonmember is added.Cancellation: the token reaches the HTTP call.
Server-side effects:
recovery_codes_deletedaudit entry;aal2with a recovery code toaal1;SDK state:
CurrentSession.User.Factorskeeps the removed factor until the user is next fetched or the session refreshes.Both match auth-js and the existing
Unenroll.Span: a new
gotrue.unenroll_recovery_codesdomain span parents the HTTP span.Deviations from supabase-js
auth.experimental.recoveryCodesis set. Here the XML docs say the feature is experimental on the auth server.Taskrather than{ id }. A user has a single recovery-code factor, so the id adds nothing for the caller._useSessionrefreshes an expired session first. This SDK uses the current access token, like its neighbours, so an expired token is rejected withbad_jwt.Tests
UnenrollRecoveryCodesTestsaal1session is rejected withinsufficient_aal. Anaal2session (after TOTP verify) without recovery codes is rejected withmfa_factor_not_found.UnenrollRecoveryCodesContractTestsinsufficient_aalandmfa_factor_not_foundrejections; Offline and NoSessionFound before the wire; cancellation; no context capture.ObservabilityContractTestsNo approval test, because there is no request body.
Changed-line coverage: 100% (9 lines). Mutation: 7/7 on changed lines (6 killed, 1 timeout), 0 survivors.
Notes
GOTRUE_MFA_RECOVERY_CODES_ENROLL_ENABLEDdefaults to false, and the Supabase CLI (2.120 and 2.122) exposes noconfig.tomlsetting for it. So the stack cannot create recovery codes, and a successful removal is pinned at the contract tier. Add the E2E once the CLI exposes the recovery-codes enroll setting.auth.mfa_recovery_codes.get_status(feat(auth): read how many MFA recovery codes the signed-in user has left #610). Whichever merges second needs a rebase over adjacent lines inIGotrueClient,IGotrueApi,Api,Client,GotrueInstrumentation.Spans,PublicAPI.Unshipped.txt, the test csproj andObservabilityContractTests.