Skip to content

Commit ce47b34

Browse files
authored
feat: support encrypted values in config (#3013)
* feat: support encrypted values in config * feat: parse smtp pass as encrypted secret * chore: parse encrypted sms secret * chore: parse encrypted hook secret * chore: parse encrypted external secret * chore: remove project ref arg from auth diff * chore: increase dupl detection threshold
1 parent 3429667 commit ce47b34

19 files changed

+472
-261
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ linters-settings:
2020
stylecheck:
2121
checks: ["all", "-ST1003"]
2222
dupl:
23-
threshold: 200
23+
threshold: 250

cmd/link.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var (
3131
return err
3232
}
3333
fsys := afero.NewOsFs()
34+
utils.Config.ProjectId = flags.ProjectRef
3435
if err := utils.LoadConfigFS(fsys); err != nil {
3536
return err
3637
}

go.mod

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ require (
1717
github.com/docker/docker v27.4.1+incompatible
1818
github.com/docker/go-connections v0.5.0
1919
github.com/docker/go-units v0.5.0
20+
github.com/ecies/go/v2 v2.0.10
2021
github.com/getsentry/sentry-go v0.31.1
2122
github.com/go-errors/errors v1.5.1
2223
github.com/go-git/go-git/v5 v5.13.1
@@ -111,6 +112,7 @@ require (
111112
github.com/daixiang0/gci v0.13.5 // indirect
112113
github.com/danieljoos/wincred v1.2.2 // indirect
113114
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
115+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
114116
github.com/denis-tingaikin/go-header v0.5.0 // indirect
115117
github.com/distribution/reference v0.6.0 // indirect
116118
github.com/dlclark/regexp2 v1.11.0 // indirect
@@ -120,6 +122,7 @@ require (
120122
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect
121123
github.com/docker/go-metrics v0.0.1 // indirect
122124
github.com/emirpasic/gods v1.18.1 // indirect
125+
github.com/ethereum/go-ethereum v1.14.12 // indirect
123126
github.com/ettle/strcase v0.2.0 // indirect
124127
github.com/fatih/color v1.18.0 // indirect
125128
github.com/fatih/structtag v1.2.0 // indirect
@@ -215,7 +218,7 @@ require (
215218
github.com/mattn/go-isatty v0.0.20 // indirect
216219
github.com/mattn/go-localereader v0.0.1 // indirect
217220
github.com/mattn/go-runewidth v0.0.16 // indirect
218-
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
221+
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
219222
github.com/mgechev/revive v1.5.1 // indirect
220223
github.com/microcosm-cc/bluemonday v1.0.25 // indirect
221224
github.com/miekg/pkcs11 v1.1.1 // indirect
@@ -244,7 +247,7 @@ require (
244247
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
245248
github.com/polyfloyd/go-errorlint v1.7.0 // indirect
246249
github.com/prometheus/client_golang v1.12.1 // indirect
247-
github.com/prometheus/client_model v0.2.0 // indirect
250+
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a // indirect
248251
github.com/prometheus/common v0.32.1 // indirect
249252
github.com/prometheus/procfs v0.7.3 // indirect
250253
github.com/quasilyte/go-ruleguard v0.4.3-0.20240823090925-0fe6f58b47b1 // indirect

go.sum

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
215215
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
216216
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
217217
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
218+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg=
219+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
218220
github.com/deepmap/oapi-codegen/v2 v2.2.0 h1:FW4f7C0Xb6EaezBSB3GYw2QGwHD5ChDflG+3xSZBdvY=
219221
github.com/deepmap/oapi-codegen/v2 v2.2.0/go.mod h1:L4zUv7ULYDtYSb/aYk/xO3OYcQU6BoU/0viULkbi2DE=
220222
github.com/denis-tingaikin/go-header v0.5.0 h1:SRdnP5ZKvcO9KKRP1KJrhFR3RrlGuD+42t4429eC9k8=
@@ -248,6 +250,8 @@ github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD
248250
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4=
249251
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE=
250252
github.com/dvsekhvalnov/jose2go v0.0.0-20170216131308-f21a8cedbbae/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM=
253+
github.com/ecies/go/v2 v2.0.10 h1:AaLxGio0MLLbvWur4rKnLzw+K9zI+wMScIDAtqCqOtU=
254+
github.com/ecies/go/v2 v2.0.10/go.mod h1:N73OyuR6tuKznit2LhXjrZ0XAQ234uKbzYz8pEPYzlI=
251255
github.com/elazarl/goproxy v1.2.3 h1:xwIyKHbaP5yfT6O9KIeYJR5549MXRQkoQMRXGztz8YQ=
252256
github.com/elazarl/goproxy v1.2.3/go.mod h1:YfEbZtqP4AetfO6d40vWchF3znWX7C7Vd6ZMfdL8z64=
253257
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
@@ -257,6 +261,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m
257261
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
258262
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
259263
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
264+
github.com/ethereum/go-ethereum v1.14.12 h1:8hl57x77HSUo+cXExrURjU/w1VhL+ShCTJrTwcCQSe4=
265+
github.com/ethereum/go-ethereum v1.14.12/go.mod h1:RAC2gVMWJ6FkxSPESfbshrcKpIokgQKsVKmAuqdekDY=
260266
github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q=
261267
github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A=
262268
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
@@ -678,8 +684,9 @@ github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRC
678684
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
679685
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
680686
github.com/mattn/go-sqlite3 v1.6.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
681-
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
682687
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
688+
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
689+
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
683690
github.com/mgechev/revive v1.5.1 h1:hE+QPeq0/wIzJwOphdVyUJ82njdd8Khp4fUIHGZHW3M=
684691
github.com/mgechev/revive v1.5.1/go.mod h1:lC9AhkJIBs5zwx8wkudyHrU+IJkrEKmpCmGMnIJPk4o=
685692
github.com/microcosm-cc/bluemonday v1.0.25 h1:4NEwSfiJ+Wva0VxN5B8OwMicaJvD8r9tlJWm9rtloEg=
@@ -792,8 +799,9 @@ github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1:
792799
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
793800
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
794801
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
795-
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
796802
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
803+
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a h1:CmF68hwI0XsOQ5UwlBopMi2Ow4Pbg32akc4KIVCOm+Y=
804+
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
797805
github.com/prometheus/common v0.0.0-20180110214958-89604d197083/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
798806
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
799807
github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc=

internal/config/push/push.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@ import (
1111
)
1212

1313
func Run(ctx context.Context, ref string, fsys afero.Fs) error {
14+
utils.Config.ProjectId = ref
1415
if err := utils.LoadConfigFS(fsys); err != nil {
1516
return err
1617
}
1718
client := config.NewConfigUpdater(*utils.GetSupabase())
18-
remote, err := utils.Config.GetRemoteByProjectRef(ref)
19-
if err != nil {
20-
// Use base config when no remote is declared
21-
remote.ProjectId = ref
22-
}
19+
remote, _ := utils.Config.GetRemoteByProjectRef(ref)
2320
fmt.Fprintln(os.Stderr, "Pushing config to project:", remote.ProjectId)
2421
console := utils.NewConsole()
2522
keep := func(name string) bool {

internal/link/link.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626

2727
func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error {
2828
copy := utils.Config.Clone()
29-
copy.Auth.HashSecrets(projectRef)
3029
original, err := cliConfig.ToTomlBytes(copy)
3130
if err != nil {
3231
fmt.Fprintln(utils.GetDebugLogger(), err)

internal/start/start.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ EOF
507507
fmt.Sprintf("GOTRUE_SMTP_HOST=%s", utils.Config.Auth.Email.Smtp.Host),
508508
fmt.Sprintf("GOTRUE_SMTP_PORT=%d", utils.Config.Auth.Email.Smtp.Port),
509509
fmt.Sprintf("GOTRUE_SMTP_USER=%s", utils.Config.Auth.Email.Smtp.User),
510-
fmt.Sprintf("GOTRUE_SMTP_PASS=%s", utils.Config.Auth.Email.Smtp.Pass),
510+
fmt.Sprintf("GOTRUE_SMTP_PASS=%s", utils.Config.Auth.Email.Smtp.Pass.Value),
511511
fmt.Sprintf("GOTRUE_SMTP_ADMIN_EMAIL=%s", utils.Config.Auth.Email.Smtp.AdminEmail),
512512
fmt.Sprintf("GOTRUE_SMTP_SENDER_NAME=%s", utils.Config.Auth.Email.Smtp.SenderName),
513513
)
@@ -550,37 +550,37 @@ EOF
550550
env,
551551
"GOTRUE_SMS_PROVIDER=twilio",
552552
"GOTRUE_SMS_TWILIO_ACCOUNT_SID="+utils.Config.Auth.Sms.Twilio.AccountSid,
553-
"GOTRUE_SMS_TWILIO_AUTH_TOKEN="+utils.Config.Auth.Sms.Twilio.AuthToken,
553+
"GOTRUE_SMS_TWILIO_AUTH_TOKEN="+utils.Config.Auth.Sms.Twilio.AuthToken.Value,
554554
"GOTRUE_SMS_TWILIO_MESSAGE_SERVICE_SID="+utils.Config.Auth.Sms.Twilio.MessageServiceSid,
555555
)
556556
case utils.Config.Auth.Sms.TwilioVerify.Enabled:
557557
env = append(
558558
env,
559559
"GOTRUE_SMS_PROVIDER=twilio_verify",
560560
"GOTRUE_SMS_TWILIO_VERIFY_ACCOUNT_SID="+utils.Config.Auth.Sms.TwilioVerify.AccountSid,
561-
"GOTRUE_SMS_TWILIO_VERIFY_AUTH_TOKEN="+utils.Config.Auth.Sms.TwilioVerify.AuthToken,
561+
"GOTRUE_SMS_TWILIO_VERIFY_AUTH_TOKEN="+utils.Config.Auth.Sms.TwilioVerify.AuthToken.Value,
562562
"GOTRUE_SMS_TWILIO_VERIFY_MESSAGE_SERVICE_SID="+utils.Config.Auth.Sms.TwilioVerify.MessageServiceSid,
563563
)
564564
case utils.Config.Auth.Sms.Messagebird.Enabled:
565565
env = append(
566566
env,
567567
"GOTRUE_SMS_PROVIDER=messagebird",
568-
"GOTRUE_SMS_MESSAGEBIRD_ACCESS_KEY="+utils.Config.Auth.Sms.Messagebird.AccessKey,
568+
"GOTRUE_SMS_MESSAGEBIRD_ACCESS_KEY="+utils.Config.Auth.Sms.Messagebird.AccessKey.Value,
569569
"GOTRUE_SMS_MESSAGEBIRD_ORIGINATOR="+utils.Config.Auth.Sms.Messagebird.Originator,
570570
)
571571
case utils.Config.Auth.Sms.Textlocal.Enabled:
572572
env = append(
573573
env,
574574
"GOTRUE_SMS_PROVIDER=textlocal",
575-
"GOTRUE_SMS_TEXTLOCAL_API_KEY="+utils.Config.Auth.Sms.Textlocal.ApiKey,
575+
"GOTRUE_SMS_TEXTLOCAL_API_KEY="+utils.Config.Auth.Sms.Textlocal.ApiKey.Value,
576576
"GOTRUE_SMS_TEXTLOCAL_SENDER="+utils.Config.Auth.Sms.Textlocal.Sender,
577577
)
578578
case utils.Config.Auth.Sms.Vonage.Enabled:
579579
env = append(
580580
env,
581581
"GOTRUE_SMS_PROVIDER=vonage",
582582
"GOTRUE_SMS_VONAGE_API_KEY="+utils.Config.Auth.Sms.Vonage.ApiKey,
583-
"GOTRUE_SMS_VONAGE_API_SECRET="+utils.Config.Auth.Sms.Vonage.ApiSecret,
583+
"GOTRUE_SMS_VONAGE_API_SECRET="+utils.Config.Auth.Sms.Vonage.ApiSecret.Value,
584584
"GOTRUE_SMS_VONAGE_FROM="+utils.Config.Auth.Sms.Vonage.From,
585585
)
586586
}
@@ -590,39 +590,39 @@ EOF
590590
env,
591591
"GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_ENABLED=true",
592592
"GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_URI="+hook.URI,
593-
"GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_SECRETS="+hook.Secrets,
593+
"GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_SECRETS="+hook.Secrets.Value,
594594
)
595595
}
596596
if hook := utils.Config.Auth.Hook.PasswordVerificationAttempt; hook != nil && hook.Enabled {
597597
env = append(
598598
env,
599599
"GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_ENABLED=true",
600600
"GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_URI="+hook.URI,
601-
"GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_SECRETS="+hook.Secrets,
601+
"GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_SECRETS="+hook.Secrets.Value,
602602
)
603603
}
604604
if hook := utils.Config.Auth.Hook.CustomAccessToken; hook != nil && hook.Enabled {
605605
env = append(
606606
env,
607607
"GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_ENABLED=true",
608608
"GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_URI="+hook.URI,
609-
"GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_SECRETS="+hook.Secrets,
609+
"GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_SECRETS="+hook.Secrets.Value,
610610
)
611611
}
612612
if hook := utils.Config.Auth.Hook.SendSMS; hook != nil && hook.Enabled {
613613
env = append(
614614
env,
615615
"GOTRUE_HOOK_SEND_SMS_ENABLED=true",
616616
"GOTRUE_HOOK_SEND_SMS_URI="+hook.URI,
617-
"GOTRUE_HOOK_SEND_SMS_SECRETS="+hook.Secrets,
617+
"GOTRUE_HOOK_SEND_SMS_SECRETS="+hook.Secrets.Value,
618618
)
619619
}
620620
if hook := utils.Config.Auth.Hook.SendEmail; hook != nil && hook.Enabled {
621621
env = append(
622622
env,
623623
"GOTRUE_HOOK_SEND_EMAIL_ENABLED=true",
624624
"GOTRUE_HOOK_SEND_EMAIL_URI="+hook.URI,
625-
"GOTRUE_HOOK_SEND_EMAIL_SECRETS="+hook.Secrets,
625+
"GOTRUE_HOOK_SEND_EMAIL_SECRETS="+hook.Secrets.Value,
626626
)
627627
}
628628

@@ -640,7 +640,7 @@ EOF
640640
env,
641641
fmt.Sprintf("GOTRUE_EXTERNAL_%s_ENABLED=%v", strings.ToUpper(name), config.Enabled),
642642
fmt.Sprintf("GOTRUE_EXTERNAL_%s_CLIENT_ID=%s", strings.ToUpper(name), config.ClientId),
643-
fmt.Sprintf("GOTRUE_EXTERNAL_%s_SECRET=%s", strings.ToUpper(name), config.Secret),
643+
fmt.Sprintf("GOTRUE_EXTERNAL_%s_SECRET=%s", strings.ToUpper(name), config.Secret.Value),
644644
fmt.Sprintf("GOTRUE_EXTERNAL_%s_SKIP_NONCE_CHECK=%t", strings.ToUpper(name), config.SkipNonceCheck),
645645
)
646646

0 commit comments

Comments
 (0)