From e129745b93679f62fb35f4a3af0bf79abffba583 Mon Sep 17 00:00:00 2001 From: Aline Shulzhenko Date: Wed, 24 Nov 2021 11:06:58 -0500 Subject: [PATCH] Ignore basic auth if server is run in CloudRun --- v2/cmd/config/cloudrun.go | 15 +++++++++++++++ v2/cmd/voucher_server/server.go | 4 ++++ 2 files changed, 19 insertions(+) create mode 100644 v2/cmd/config/cloudrun.go diff --git a/v2/cmd/config/cloudrun.go b/v2/cmd/config/cloudrun.go new file mode 100644 index 00000000..38f88ae3 --- /dev/null +++ b/v2/cmd/config/cloudrun.go @@ -0,0 +1,15 @@ +package config + +import ( + "os" + "strconv" +) + +func IsCloudRun() bool { + isCloudRun := os.Getenv("IS_CLOUDRUN") + isCloudRunBool, err := strconv.ParseBool(isCloudRun) + if err != nil { + return false + } + return isCloudRunBool +} diff --git a/v2/cmd/voucher_server/server.go b/v2/cmd/voucher_server/server.go index 5a1f8532..73b47573 100644 --- a/v2/cmd/voucher_server/server.go +++ b/v2/cmd/voucher_server/server.go @@ -39,6 +39,10 @@ var serverCmd = &cobra.Command{ config.RegisterDynamicChecks() + if config.IsCloudRun() { + serverConfig.RequireAuth = false + } + voucherServer := server.NewServer(&serverConfig, secrets, metricsClient) for groupName, checks := range config.GetRequiredChecksFromConfig() {