Skip to content

Commit

Permalink
feat: replace name with URI
Browse files Browse the repository at this point in the history
  • Loading branch information
joel authored and joel committed Jan 18, 2024
1 parent d8be11a commit 11b86d9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
8 changes: 4 additions & 4 deletions internal/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,23 +492,23 @@ EOF
env = append(
env,
"GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_ENABLED=true",
"GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_NAME="+utils.Config.Auth.Hook.MFAVerificationAttempt.Name,
"GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_URI="+utils.Config.Auth.Hook.MFAVerificationAttempt.URI,
)
}

if utils.Config.Auth.Hook.PasswordVerificationAttempt.Enabled {
env = append(
env,
"GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_ENABLED=true",
"GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_NAME="+utils.Config.Auth.Hook.PasswordVerificationAttempt.Name,
"GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_URI="+utils.Config.Auth.Hook.PasswordVerificationAttempt.URI,
)
}

if utils.Config.Auth.Hook.PasswordVerificationAttempt.Enabled {
if utils.Config.Auth.Hook.CustomAccessToken.Enabled {
env = append(
env,
"GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_ENABLED=true",
"GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_NAME="+utils.Config.Auth.Hook.CustomAccessToken.Name,
"GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_URI="+utils.Config.Auth.Hook.CustomAccessToken.URI,
)
}

Expand Down
24 changes: 22 additions & 2 deletions internal/utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ var Config = config{
"workos": {},
"zoom": {},
},
Hook: hook{},
JwtExpiry: 3600,
JwtSecret: defaultJwtSecret,
},
Expand Down Expand Up @@ -311,7 +312,7 @@ type (
EnableRefreshTokenRotation bool `toml:"enable_refresh_token_rotation"`
RefreshTokenReuseInterval uint `toml:"refresh_token_reuse_interval"`
EnableManualLinking bool `toml:"enable_manual_linking"`
Hook hook `toml:"hook"`
Hook hook `toml:"hook" mapstructure:"hook"`

EnableSignup bool `toml:"enable_signup"`
Email email `toml:"email"`
Expand Down Expand Up @@ -356,7 +357,7 @@ type (

extensibilityPointConfig struct {
Enabled bool `toml:"enabled"`
Name string `toml:"hook_name"`
URI string `toml:"uri"`
}

twilioConfig struct {
Expand Down Expand Up @@ -651,6 +652,25 @@ func LoadConfigFS(fsys afero.Fs) error {
return err
}
}

if Config.Auth.Hook.MFAVerificationAttempt.Enabled {
if Config.Auth.Hook.MFAVerificationAttempt.URI == "" {
return errors.New("Missing required field in config: auth.hook.mfa_verification_atempt.uri")
}
}

if Config.Auth.Hook.PasswordVerificationAttempt.Enabled {
if Config.Auth.Hook.PasswordVerificationAttempt.URI == "" {
return errors.New("Missing required field in config: auth.hook.password_verification_attempt.uri")
}
}

if Config.Auth.Hook.CustomAccessToken.Enabled {
if Config.Auth.Hook.CustomAccessToken.URI == "" {
return errors.New("Missing required field in config: auth.hook.custom_access_token.uri")
}
}

// Validate oauth config
for ext, provider := range Config.Auth.External {
if !provider.Enabled {
Expand Down
2 changes: 1 addition & 1 deletion internal/utils/templates/init_config.test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ template = "Your code is {{ `{{ .Code }}` }} ."

[auth.hook.custom_access_token]
enabled = true
hook_name = "custom_access_token_hook"
uri = "pg-functions://postgres/auth/custom-access-token-hook"


# Configure one of the supported SMS providers: `twilio`, `twilio_verify`, `messagebird`, `textlocal`, `vonage`.
Expand Down
2 changes: 1 addition & 1 deletion internal/utils/templates/init_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ template = "Your code is {{ `{{ .Code }}` }} ."

[auth.hook.custom_access_token]
# enabled = true
# hook_name = "your_hook_name"
# uri = "pg-functions://<database>/<schema>/<hook_name>"


# Configure one of the supported SMS providers: `twilio`, `twilio_verify`, `messagebird`, `textlocal`, `vonage`.
Expand Down

0 comments on commit 11b86d9

Please sign in to comment.