Skip to content

Commit

Permalink
feat: add initial secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
J0 committed Apr 6, 2024
1 parent 024d247 commit 27d20e3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
16 changes: 16 additions & 0 deletions internal/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,22 @@ EOF
)
}

if utils.Config.Auth.Hook.SendSMS.Enabled {
env = append(
env,
"GOTRUE_HOOK_SEND_SMS_ENABLED=true",
"GOTRUE_HOOK_SEND_SMS_URI="+utils.Config.Auth.Hook.SendSMS.URI,
)
}

if utils.Config.Auth.Hook.SendEmail.Enabled {
env = append(
env,
"GOTRUE_HOOK_SEND_EMAIL_ENABLED=true",
"GOTRUE_HOOK_SEND_Email_URI="+utils.Config.Auth.Hook.SendEmail.URI,
)
}

for name, config := range utils.Config.Auth.External {
env = append(
env,
Expand Down
24 changes: 22 additions & 2 deletions internal/utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,14 @@ type (
MFAVerificationAttempt hookConfig `toml:"mfa_verification_attempt"`
PasswordVerificationAttempt hookConfig `toml:"password_verification_attempt"`
CustomAccessToken hookConfig `toml:"custom_access_token"`
SendSMS hookConfig `toml:"send_sms"`
SendEmail hookConfig `toml:"send_email"`
}

hookConfig struct {
Enabled bool `toml:"enabled"`
URI string `toml:"uri"`
Enabled bool `toml:"enabled"`
URI string `toml:"uri"`
HTTPHookSecrets string `toml:"secrets"`
}

twilioConfig struct {
Expand Down Expand Up @@ -673,6 +676,23 @@ func LoadConfigFS(fsys afero.Fs) error {
}
}

if Config.Auth.Hook.SendSMS.Enabled {
if Config.Auth.Hook.SendSMS.URI == "" {
return errors.New("Missing required field in config: auth.hook.send_sms.uri")
}
if !strings.HasPrefix(Config.Auth.Hook.SendSMS, "http") {
return errors.New("Invalid HTTP hook config: auth.hook.send_sms.uri should be a http or https URL")

Check failure on line 684 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix

Check failure on line 684 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix

Check failure on line 684 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix

Check failure on line 684 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Start

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix

Check failure on line 684 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix

Check failure on line 684 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix

Check failure on line 684 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix

Check failure on line 684 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix

Check failure on line 684 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix
}
}
if Config.Auth.Hook.SendEmail.Enabled {
if Config.Auth.Hook.SendSMS.URI == "" {
return errors.New("Missing required field in config: auth.hook.custom_access_token.uri")
}
if !strings.HasPrefix(Config.Auth.Hook.SendSMS, "http") {
return errors.New("Invalid HTTP hook config: auth.hook.send_email.uri should be a http or https URL")

Check failure on line 692 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix) (typecheck)

Check failure on line 692 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix) (typecheck)

Check failure on line 692 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix) (typecheck)

Check failure on line 692 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Start

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix

Check failure on line 692 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix

Check failure on line 692 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix

Check failure on line 692 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix

Check failure on line 692 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix

Check failure on line 692 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

cannot use Config.Auth.Hook.SendSMS (variable of type hookConfig) as string value in argument to strings.HasPrefix
}
}

// Validate oauth config
for ext, provider := range Config.Auth.External {
if !provider.Enabled {
Expand Down

0 comments on commit 27d20e3

Please sign in to comment.