Skip to content

Commit

Permalink
fix(auth): support email otp length and expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
sweatybridge committed Oct 29, 2024
1 parent b322db7 commit 44c21a8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,8 @@ EOF
fmt.Sprintf("GOTRUE_EXTERNAL_EMAIL_ENABLED=%v", utils.Config.Auth.Email.EnableSignup),
fmt.Sprintf("GOTRUE_MAILER_SECURE_EMAIL_CHANGE_ENABLED=%v", utils.Config.Auth.Email.DoubleConfirmChanges),
fmt.Sprintf("GOTRUE_MAILER_AUTOCONFIRM=%v", !utils.Config.Auth.Email.EnableConfirmations),
fmt.Sprintf("GOTRUE_MAILER_OTP_LENGTH=%v", utils.Config.Auth.Email.OtpLength),
fmt.Sprintf("GOTRUE_MAILER_OTP_EXP=%v", utils.Config.Auth.Email.OtpExpiry),

fmt.Sprintf("GOTRUE_EXTERNAL_ANONYMOUS_USERS_ENABLED=%v", utils.Config.Auth.EnableAnonymousSignIns),

Expand Down
2 changes: 2 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ type (
Template map[string]emailTemplate `toml:"template"`
Smtp smtp `toml:"smtp"`
MaxFrequency time.Duration `toml:"max_frequency"`
OtpLength uint `toml:"otp_length"`
OtpExpiry uint `toml:"otp_expiry"`
}

smtp struct {
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/templates/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ enable_confirmations = false
secure_password_change = false
# Controls the minimum amount of time that must pass before sending another signup confirmation or password reset email.
max_frequency = "1s"
# Number of characters used in the email OTP.
otp_length = 6
# Number of seconds before the email OTP expires (defaults to 1 hour).
otp_expiry = 3600

# Use a production-ready SMTP server
# [auth.email.smtp]
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/testdata/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ double_confirm_changes = true
enable_confirmations = false
# Controls the minimum amount of time that must pass before sending another signup confirmation or password reset email.
max_frequency = "1s"
# Number of characters used in the email OTP.
otp_length = 6
# Number of seconds before the email OTP expires.
otp_expiry = 300

# Use a production-ready SMTP server
[auth.email.smtp]
Expand Down

0 comments on commit 44c21a8

Please sign in to comment.