Skip to content

Commit

Permalink
Add option for logging secrets
Browse files Browse the repository at this point in the history
If a secret key seed is provided in the environment, the gateway logs it
in the clear. This commit gates that behavior on a new environment
variable `LOG_SECRETS`, which is off by default.
  • Loading branch information
tgeoghegan authored and cjpatton committed May 7, 2024
1 parent 0a8325a commit 17d3a61
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const (
monitoringServiceNameEnvironmentVariable = "MONITORING_SERVICE_NAME"
gatewayDebugEnvironmentVariable = "GATEWAY_DEBUG"
gatewayVerboseEnvironmentVariable = "VERBOSE"
logSecretsEnvironmentVariable = "LOG_SECRETS"
)

type gatewayServer struct {
Expand Down Expand Up @@ -128,9 +129,15 @@ func main() {
port = defaultPort
}

logSecrets := getBoolEnv(logSecretsEnvironmentVariable, false)

var seed []byte
if seedHex := os.Getenv(secretSeedEnvironmentVariable); seedHex != "" {
log.Printf("Using Secret Key Seed : [%v]", seedHex)
if logSecrets {
log.Printf("Using Secret Key Seed: [%v]", seedHex)
} else {
log.Print("Using Secret Key Seed provided in environment variable")
}
var err error
seed, err = hex.DecodeString(seedHex)
if err != nil {
Expand Down

0 comments on commit 17d3a61

Please sign in to comment.