From 77d58976ae624dbb7f8abee041dd4557aab81109 Mon Sep 17 00:00:00 2001 From: Joel Lee Date: Fri, 13 Sep 2024 12:34:58 +0300 Subject: [PATCH] feat: add webauthn configuration variables (#1773) ## What kind of change does this PR introduce? Add `MFA_WEB_AUTHN_ENROLL_ENABLED` and `MFA_WEB_AUTHN_VERIFY_ENABLED` in support of the MFA WebAuthn implementation. --- example.env | 3 +++ internal/conf/configuration.go | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/example.env b/example.env index 01371183e..e645c96e9 100644 --- a/example.env +++ b/example.env @@ -233,3 +233,6 @@ GOTRUE_HOOK_CUSTOM_SMS_PROVIDER_SECRET="" # Test OTP Config GOTRUE_SMS_TEST_OTP=":, :..." GOTRUE_SMS_TEST_OTP_VALID_UNTIL="" # (e.g. 2023-09-29T08:14:06Z) + +GOTRUE_MFA_WEB_AUTHN_ENROLL_ENABLED="false" +GOTRUE_MFA_WEB_AUTHN_VERIFY_ENABLED="false" diff --git a/internal/conf/configuration.go b/internal/conf/configuration.go index a4315866c..792061a1a 100644 --- a/internal/conf/configuration.go +++ b/internal/conf/configuration.go @@ -111,18 +111,22 @@ type JWTConfiguration struct { } type MFAFactorTypeConfiguration struct { + EnrollEnabled bool `json:"enroll_enabled" split_words:"true" default:"false"` + VerifyEnabled bool `json:"verify_enabled" split_words:"true" default:"false"` +} + +type TOTPFactorTypeConfiguration struct { EnrollEnabled bool `json:"enroll_enabled" split_words:"true" default:"true"` VerifyEnabled bool `json:"verify_enabled" split_words:"true" default:"true"` } type PhoneFactorTypeConfiguration struct { // Default to false in order to ensure Phone MFA is opt-in - EnrollEnabled bool `json:"enroll_enabled" split_words:"true" default:"false"` - VerifyEnabled bool `json:"verify_enabled" split_words:"true" default:"false"` - OtpLength int `json:"otp_length" split_words:"true"` - SMSTemplate *template.Template `json:"-"` - MaxFrequency time.Duration `json:"max_frequency" split_words:"true"` - Template string `json:"template"` + MFAFactorTypeConfiguration + OtpLength int `json:"otp_length" split_words:"true"` + SMSTemplate *template.Template `json:"-"` + MaxFrequency time.Duration `json:"max_frequency" split_words:"true"` + Template string `json:"template"` } // MFAConfiguration holds all the MFA related Configuration @@ -133,7 +137,8 @@ type MFAConfiguration struct { MaxEnrolledFactors float64 `split_words:"true" default:"10"` MaxVerifiedFactors int `split_words:"true" default:"10"` Phone PhoneFactorTypeConfiguration `split_words:"true"` - TOTP MFAFactorTypeConfiguration `split_words:"true"` + TOTP TOTPFactorTypeConfiguration `split_words:"true"` + WebAuthn MFAFactorTypeConfiguration `split_words:"true"` } type APIConfiguration struct {