Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: treat GOTRUE_MFA_ENABLED as meaning TOTP enabled on enroll and verify #1694

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions internal/api/mfa.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ func (a *API) EnrollFactor(w http.ResponseWriter, r *http.Request) error {
}
return a.enrollPhoneFactor(w, r, params)
case models.TOTP:
if !config.MFA.TOTP.EnrollEnabled {
// Prior to the introduction of MFA.TOTP.EnrollEnabled,
// MFA.Enabled was used to configure whether TOTP was on. So
// both have to be set to false to regard the feature as
// disabled.
if !config.MFA.Enabled && !config.MFA.TOTP.EnrollEnabled {
return unprocessableEntityError(ErrorCodeMFATOTPEnrollDisabled, "MFA enroll is disabled for TOTP")
}
default:
Expand Down Expand Up @@ -362,7 +366,11 @@ func (a *API) ChallengeFactor(w http.ResponseWriter, r *http.Request) error {
return a.challengePhoneFactor(w, r)

case models.TOTP:
if !config.MFA.TOTP.VerifyEnabled {
// Prior to the introduction of MFA.TOTP.VerifyEnabled,
// MFA.Enabled was used to configure whether TOTP was on. So
// both have to be set to false to regard the feature as
// disabled.
if !config.MFA.Enabled && !config.MFA.TOTP.VerifyEnabled {
return unprocessableEntityError(ErrorCodeMFATOTPEnrollDisabled, "MFA verification is disabled for TOTP")
}
default:
Expand Down
4 changes: 3 additions & 1 deletion internal/conf/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ type PhoneFactorTypeConfiguration struct {

// MFAConfiguration holds all the MFA related Configuration
type MFAConfiguration struct {
Enabled bool `default:"false"`
// Enabled is deprecated, but still used to signal TOTP.EnrollEnabled and TOTP.VerifyEnabled.
Enabled bool `default:"false"`

ChallengeExpiryDuration float64 `json:"challenge_expiry_duration" default:"300" split_words:"true"`
FactorExpiryDuration time.Duration `json:"factor_expiry_duration" default:"300s" split_words:"true"`
RateLimitChallengeAndVerify float64 `split_words:"true" default:"15"`
Expand Down
Loading