From a06429e3300846e9307e23ba692f459dbd480bd8 Mon Sep 17 00:00:00 2001 From: Nicholas Moschopoulos Date: Mon, 15 Jan 2024 20:37:25 -0500 Subject: [PATCH 1/6] Update start.go --- internal/start/start.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/start/start.go b/internal/start/start.go index 98c958cab..38e000089 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -380,6 +380,7 @@ EOF "GOTRUE_SITE_URL=" + utils.Config.Auth.SiteUrl, "GOTRUE_URI_ALLOW_LIST=" + strings.Join(utils.Config.Auth.AdditionalRedirectUrls, ","), fmt.Sprintf("GOTRUE_DISABLE_SIGNUP=%v", !utils.Config.Auth.EnableSignup), + fmt.Sprintf("GOTRUE_SECURITY_MANUAL_LINKING_ENABLED=%v", utils.Config.Auth.EnableManualLinking) "GOTRUE_JWT_ADMIN_ROLES=service_role", "GOTRUE_JWT_AUD=authenticated", From d9c08f28b15d6eddbccfa01c982cc3dcadeb3161 Mon Sep 17 00:00:00 2001 From: Nico Moschopoulos Date: Mon, 15 Jan 2024 20:40:27 -0500 Subject: [PATCH 2/6] Add to config.go --- internal/utils/config.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/utils/config.go b/internal/utils/config.go index 71ca3fdea..48631c5b4 100644 --- a/internal/utils/config.go +++ b/internal/utils/config.go @@ -310,10 +310,11 @@ type ( EnableRefreshTokenRotation bool `toml:"enable_refresh_token_rotation"` RefreshTokenReuseInterval uint `toml:"refresh_token_reuse_interval"` - EnableSignup bool `toml:"enable_signup"` - Email email `toml:"email"` - Sms sms `toml:"sms"` - External map[string]provider + EnableSignup bool `toml:"enable_signup"` + EnableManualLinking bool `toml:"enable_manual_linking"` + Email email `toml:"email"` + Sms sms `toml:"sms"` + External map[string]provider // Custom secrets can be injected from .env file JwtSecret string `toml:"-" mapstructure:"jwt_secret"` From 903313ca97a1d651b071e88053b64fd9518ec7b1 Mon Sep 17 00:00:00 2001 From: Nico Moschopoulos Date: Mon, 15 Jan 2024 20:42:24 -0500 Subject: [PATCH 3/6] Missing comma --- internal/start/start.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/start/start.go b/internal/start/start.go index 38e000089..a64a3fd59 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -380,7 +380,7 @@ EOF "GOTRUE_SITE_URL=" + utils.Config.Auth.SiteUrl, "GOTRUE_URI_ALLOW_LIST=" + strings.Join(utils.Config.Auth.AdditionalRedirectUrls, ","), fmt.Sprintf("GOTRUE_DISABLE_SIGNUP=%v", !utils.Config.Auth.EnableSignup), - fmt.Sprintf("GOTRUE_SECURITY_MANUAL_LINKING_ENABLED=%v", utils.Config.Auth.EnableManualLinking) + fmt.Sprintf("GOTRUE_SECURITY_MANUAL_LINKING_ENABLED=%v", utils.Config.Auth.EnableManualLinking), "GOTRUE_JWT_ADMIN_ROLES=service_role", "GOTRUE_JWT_AUD=authenticated", From d1d5db06cb8e77ec6289568f7085d3b60531d11f Mon Sep 17 00:00:00 2001 From: Nico Moschopoulos Date: Mon, 15 Jan 2024 20:51:38 -0500 Subject: [PATCH 4/6] Init COnfig --- internal/utils/config.go | 8 ++++---- internal/utils/templates/init_config.toml | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/utils/config.go b/internal/utils/config.go index 48631c5b4..88537b4dc 100644 --- a/internal/utils/config.go +++ b/internal/utils/config.go @@ -310,11 +310,11 @@ type ( EnableRefreshTokenRotation bool `toml:"enable_refresh_token_rotation"` RefreshTokenReuseInterval uint `toml:"refresh_token_reuse_interval"` - EnableSignup bool `toml:"enable_signup"` + EnableSignup bool `toml:"enable_signup"` EnableManualLinking bool `toml:"enable_manual_linking"` - Email email `toml:"email"` - Sms sms `toml:"sms"` - External map[string]provider + Email email `toml:"email"` + Sms sms `toml:"sms"` + External map[string]provider // Custom secrets can be injected from .env file JwtSecret string `toml:"-" mapstructure:"jwt_secret"` diff --git a/internal/utils/templates/init_config.toml b/internal/utils/templates/init_config.toml index 06a5dc755..b89a9fc52 100644 --- a/internal/utils/templates/init_config.toml +++ b/internal/utils/templates/init_config.toml @@ -81,6 +81,8 @@ enable_refresh_token_rotation = true refresh_token_reuse_interval = 10 # Allow/disallow new user signups to your project. enable_signup = true +# Allow/disallow testing manual linking of accounts +enable_manual_linking = false [auth.email] # Allow/disallow new user signups via email to your project. From 9596f425461edfc933cfae419565bc923167c8d6 Mon Sep 17 00:00:00 2001 From: Nico Moschopoulos Date: Tue, 16 Jan 2024 08:57:12 -0500 Subject: [PATCH 5/6] review --- internal/start/start.go | 2 +- internal/utils/config.go | 12 ++++++------ internal/utils/templates/init_config.test.toml | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/internal/start/start.go b/internal/start/start.go index a64a3fd59..e3e64cd43 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -380,7 +380,6 @@ EOF "GOTRUE_SITE_URL=" + utils.Config.Auth.SiteUrl, "GOTRUE_URI_ALLOW_LIST=" + strings.Join(utils.Config.Auth.AdditionalRedirectUrls, ","), fmt.Sprintf("GOTRUE_DISABLE_SIGNUP=%v", !utils.Config.Auth.EnableSignup), - fmt.Sprintf("GOTRUE_SECURITY_MANUAL_LINKING_ENABLED=%v", utils.Config.Auth.EnableManualLinking), "GOTRUE_JWT_ADMIN_ROLES=service_role", "GOTRUE_JWT_AUD=authenticated", @@ -416,6 +415,7 @@ EOF fmt.Sprintf("GOTRUE_SECURITY_REFRESH_TOKEN_ROTATION_ENABLED=%v", utils.Config.Auth.EnableRefreshTokenRotation), fmt.Sprintf("GOTRUE_SECURITY_REFRESH_TOKEN_REUSE_INTERVAL=%v", utils.Config.Auth.RefreshTokenReuseInterval), + fmt.Sprintf("GOTRUE_SECURITY_MANUAL_LINKING_ENABLED=%v", utils.Config.Auth.EnableManualLinking), } for id, tmpl := range utils.Config.Auth.Email.Template { diff --git a/internal/utils/config.go b/internal/utils/config.go index 88537b4dc..c84423de0 100644 --- a/internal/utils/config.go +++ b/internal/utils/config.go @@ -309,12 +309,12 @@ type ( JwtExpiry uint `toml:"jwt_expiry"` EnableRefreshTokenRotation bool `toml:"enable_refresh_token_rotation"` RefreshTokenReuseInterval uint `toml:"refresh_token_reuse_interval"` + EnableManualLinking bool `toml:"enable_manual_linking"` - EnableSignup bool `toml:"enable_signup"` - EnableManualLinking bool `toml:"enable_manual_linking"` - Email email `toml:"email"` - Sms sms `toml:"sms"` - External map[string]provider + EnableSignup bool `toml:"enable_signup"` + Email email `toml:"email"` + Sms sms `toml:"sms"` + External map[string]provider // Custom secrets can be injected from .env file JwtSecret string `toml:"-" mapstructure:"jwt_secret"` @@ -735,7 +735,7 @@ func InitConfig(params InitParams, fsys afero.Fs) error { if err := MkdirIfNotExistFS(fsys, filepath.Dir(ConfigPath)); err != nil { return err } - f, err := fsys.OpenFile(ConfigPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0644) + f, err := fsys.OpenFile(ConfigPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o644) if err != nil { return errors.Errorf("failed to create config file: %w", err) } diff --git a/internal/utils/templates/init_config.test.toml b/internal/utils/templates/init_config.test.toml index e62b55ab9..f6fefffcc 100644 --- a/internal/utils/templates/init_config.test.toml +++ b/internal/utils/templates/init_config.test.toml @@ -81,6 +81,8 @@ enable_refresh_token_rotation = true refresh_token_reuse_interval = 10 # Allow/disallow new user signups to your project. enable_signup = true +# Allow/disallow testing manual linking of accounts +enable_manual_linking = true [auth.email] # Allow/disallow new user signups via email to your project. From 1897c1c4e0d92ee5fc4e1a8f1999d7d3a1e716fd Mon Sep 17 00:00:00 2001 From: Nicholas Moschopoulos Date: Tue, 16 Jan 2024 09:18:01 -0500 Subject: [PATCH 6/6] Update internal/utils/config.go Co-authored-by: Han Qiao --- internal/utils/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/utils/config.go b/internal/utils/config.go index c84423de0..6703c86f9 100644 --- a/internal/utils/config.go +++ b/internal/utils/config.go @@ -735,7 +735,7 @@ func InitConfig(params InitParams, fsys afero.Fs) error { if err := MkdirIfNotExistFS(fsys, filepath.Dir(ConfigPath)); err != nil { return err } - f, err := fsys.OpenFile(ConfigPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o644) + f, err := fsys.OpenFile(ConfigPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0644) if err != nil { return errors.Errorf("failed to create config file: %w", err) }