Skip to content

Commit

Permalink
Ignore basic auth if server is run in CloudRun
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnsh committed Nov 24, 2021
1 parent 5e8f771 commit e129745
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions v2/cmd/config/cloudrun.go
Original file line number Diff line number Diff line change
@@ -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
}
4 changes: 4 additions & 0 deletions v2/cmd/voucher_server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit e129745

Please sign in to comment.