Browse Source

Complain if the env set in SecretEnv cannot be found

Signed-off-by: Sandro <sandro.jaeckel@gmail.com>
pull/3218/head
Sandro 2 years ago committed by Sandro Jäckel
parent
commit
39ecb13cc2
No known key found for this signature in database
GPG Key ID: 3AF5A43A3EECC2E5
  1. 3
      cmd/dex/config.go
  2. 12
      cmd/dex/serve.go

3
cmd/dex/config.go

@ -103,6 +103,9 @@ func (p *password) UnmarshalJSON(b []byte) error {
})
if len(data.Hash) == 0 && len(data.HashFromEnv) > 0 {
data.Hash = os.Getenv(data.HashFromEnv)
if data.Hash == "" {
return fmt.Errorf("invalid config: could not find HashFromEnv %q", data.HashFromEnv)
}
}
if len(data.Hash) == 0 {
return fmt.Errorf("no password hash provided")

12
cmd/dex/serve.go

@ -188,7 +188,11 @@ func runServe(options serveOptions) error {
if client.ID != "" {
return fmt.Errorf("invalid config: ID and IDEnv fields are exclusive for client %q", client.ID)
}
c.StaticClients[i].ID = os.Getenv(client.IDEnv)
id := os.Getenv(client.IDEnv)
if id == "" {
return fmt.Errorf("invalid config: could not find IDEnv %q", id)
}
c.StaticClients[i].ID = id
}
if client.Secret == "" && client.SecretEnv == "" && !client.Public {
return fmt.Errorf("invalid config: Secret or SecretEnv field is required for client %q", client.ID)
@ -197,7 +201,11 @@ func runServe(options serveOptions) error {
if client.Secret != "" {
return fmt.Errorf("invalid config: Secret and SecretEnv fields are exclusive for client %q", client.ID)
}
c.StaticClients[i].Secret = os.Getenv(client.SecretEnv)
secret := os.Getenv(client.SecretEnv)
if secret == "" {
return fmt.Errorf("invalid config: could not find SecretEnv %q", client.SecretEnv)
}
c.StaticClients[i].Secret = secret
}
logger.Infof("config static client: %s", client.Name)
}

Loading…
Cancel
Save