fix: support = delimiter in GOTRUE_SMS_TEST_OTP env var#2529
Open
Reckz69 wants to merge 3 commits into
Open
Conversation
Co-authored-by: depthfirst-app[bot] <184448029+depthfirst-app[bot]@users.noreply.github.com>
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.
Fix GOTRUE_SMS_TEST_OTP parsing for equals-delimited values
Fixes supabase/supabase#45832
Summary
Fixes an issue where
GOTRUE_SMS_TEST_OTPfails to parse when values use=as the key-value delimiter (e.g.phone=otp), which is the format injected by the hosted Supabase platform.This caused Auth startup failures when SMS test OTPs were configured in hosted environments.
Root Cause
The project currently relies on
kelseyhightower/envconfig's default map decoder for parsingGOTRUE_SMS_TEST_OTP.The default decoder only supports colon-delimited entries:
When the hosted platform injects:
envconfigfails during startup with:Solution
Introduced a custom
TestOTPMaptype implementing theenvconfig.Decoderinterface, following the same decoder pattern already used elsewhere in the codebase (JwtKeysDecoder,Rate,HTTPHookSecrets, etc.).The new decoder supports all of the following formats:
JSON object
{"phone":"otp"}Colon-delimited (backward compatible)
Equals-delimited (hosted platform compatible)
This preserves backward compatibility while adding support for the hosted platform injection format.
Changes
internal/conf/configuration.goTestOTPMapwith customDecode()implementation and updatedTestOTPfield typeinternal/conf/configuration_test.gointernal/api/phone_test.goTestOTPfield typeinternal/api/anonymous_test.goTestOTPfield typeTesting
Unit Tests
Added coverage for:
All tests passing:
End-to-End Validation
Validated against the real Auth flow using a Postgres-backed test environment:
Result:
--- PASS: TestPhone (0.15s) --- PASS: TestPhone/TestSendPhoneConfirmationWithTestOTP --- PASS: send_confirmation_otp --- PASS: send_phone_change_otp --- PASS: send_recovery_otpCI / Quality Checks
gofmtgo vetgo build ./...staticcheckgosecgovulncheck