Option to add staticPasswords from environment variables

Signed-off-by: justin-slowik <justin.slowik@thermofisher.com>
This commit is contained in:
krishnadurai 2019-12-13 16:33:21 -08:00 committed by justin-slowik
parent 62efe7bf07
commit 776aa9dd53
2 changed files with 7 additions and 1 deletions

View file

@ -103,8 +103,12 @@ func (p *password) UnmarshalJSON(b []byte) error {
data.Hash = os.Getenv(data.HashFromEnv) data.Hash = os.Getenv(data.HashFromEnv)
} }
if len(data.Hash) == 0 { if len(data.Hash) == 0 {
if len(data.HashFromEnv) > 0 {
data.Hash = os.Getenv(data.HashFromEnv)
} else {
return fmt.Errorf("no password hash provided") return fmt.Errorf("no password hash provided")
} }
}
// If this value is a valid bcrypt, use it. // If this value is a valid bcrypt, use it.
_, bcryptErr := bcrypt.Cost([]byte(data.Hash)) _, bcryptErr := bcrypt.Cost([]byte(data.Hash))

View file

@ -4,6 +4,8 @@ import (
"os" "os"
"testing" "testing"
"github.com/dexidp/dex/server"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
"github.com/kylelemons/godebug/pretty" "github.com/kylelemons/godebug/pretty"