fix: don't bypass double_confirm_changes when mailer_autoconfirm is true#2601
Open
shkuls wants to merge 3 commits into
Open
fix: don't bypass double_confirm_changes when mailer_autoconfirm is true#2601shkuls wants to merge 3 commits into
shkuls wants to merge 3 commits into
Conversation
When GOTRUE_MAILER_AUTOCONFIRM=true, the guard in emailChangeVerify that holds the flow after the first OTP is verified was skipped entirely due to the !config.Mailer.Autoconfirm condition. This caused the email change to commit after a single confirmation regardless of SecureEmailChangeEnabled. Autoconfirm and SecureEmailChangeEnabled are orthogonal: autoconfirm applies to signup flows, SecureEmailChangeEnabled applies to email change flows. Remove !Autoconfirm from the guard so double_confirm_changes works independently of the autoconfirm setting. Fixes supabase#2600
…true Adds a regression test for the bug where SecureEmailChangeEnabled was silently bypassed when Autoconfirm=true. The test asserts that: - after verifying the first token, the email has NOT changed and EmailChangeConfirmStatus is singleConfirmation - only after verifying the second token does the email change commit Covers: supabase#2600
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.
Problem
Closes #2600
GOTRUE_MAILER_SECURE_EMAIL_CHANGE_ENABLED=true(double_confirm_changes) is silently bypassed whenGOTRUE_MAILER_AUTOCONFIRM=true. The email change commits after a single confirmation instead of requiring both the old and new address to confirm.Related upstream reports:
Root cause
In
emailChangeVerify, the guard that holds the flow at "one confirmed, waiting for the second" is:GOTRUE_MAILER_AUTOCONFIRMcontrols whether new signups require email confirmation. It is completely unrelated to email change confirmation. ANDing it here means any deployment withmailer_autoconfirm=true— including the default self-hosted and local dev configuration — silently disablesdouble_confirm_changeswith no warning or error.Verified locally
Reproduced the bug against
v2.186.0withGOTRUE_MAILER_AUTOCONFIRM=trueandGOTRUE_MAILER_SECURE_EMAIL_CHANGE_ENABLED=true:otp_expired