|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package main |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"bytes" |
|
|
|
|
"encoding/base64" |
|
|
|
|
"encoding/json" |
|
|
|
|
"fmt" |
|
|
|
|
@ -23,6 +24,15 @@ import (
|
|
|
|
|
"github.com/dexidp/dex/storage/sql" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func configUnmarshaller(b []byte, v interface{}) error { |
|
|
|
|
if featureflags.ConfigDisallowUnknownFields.Enabled() { |
|
|
|
|
return json.Unmarshal(b, v) |
|
|
|
|
} |
|
|
|
|
dec := json.NewDecoder(bytes.NewReader(b)) |
|
|
|
|
dec.DisallowUnknownFields() |
|
|
|
|
return dec.Decode(v) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Config is the config format for the main application.
|
|
|
|
|
type Config struct { |
|
|
|
|
Issuer string `json:"issuer"` |
|
|
|
|
@ -109,7 +119,7 @@ func (p *password) UnmarshalJSON(b []byte) error {
|
|
|
|
|
HashFromEnv string `json:"hashFromEnv"` |
|
|
|
|
Groups []string `json:"groups"` |
|
|
|
|
} |
|
|
|
|
if err := json.Unmarshal(b, &data); err != nil { |
|
|
|
|
if err := configUnmarshaller(b, &data); err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
*p = password(storage.Password{ |
|
|
|
|
@ -333,7 +343,7 @@ func (s *Storage) UnmarshalJSON(b []byte) error {
|
|
|
|
|
Type string `json:"type"` |
|
|
|
|
Config json.RawMessage `json:"config"` |
|
|
|
|
} |
|
|
|
|
if err := json.Unmarshal(b, &store); err != nil { |
|
|
|
|
if err := configUnmarshaller(b, &store); err != nil { |
|
|
|
|
return fmt.Errorf("parse storage: %v", err) |
|
|
|
|
} |
|
|
|
|
f, ok := storages[store.Type] |
|
|
|
|
@ -346,7 +356,7 @@ func (s *Storage) UnmarshalJSON(b []byte) error {
|
|
|
|
|
data := []byte(store.Config) |
|
|
|
|
if featureflags.ExpandEnv.Enabled() { |
|
|
|
|
var rawMap map[string]interface{} |
|
|
|
|
if err := json.Unmarshal(store.Config, &rawMap); err != nil { |
|
|
|
|
if err := configUnmarshaller(store.Config, &rawMap); err != nil { |
|
|
|
|
return fmt.Errorf("unmarshal config for env expansion: %v", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -363,7 +373,7 @@ func (s *Storage) UnmarshalJSON(b []byte) error {
|
|
|
|
|
data = expandedData |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if err := json.Unmarshal(data, storageConfig); err != nil { |
|
|
|
|
if err := configUnmarshaller(data, storageConfig); err != nil { |
|
|
|
|
return fmt.Errorf("parse storage config: %v", err) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -462,7 +472,7 @@ func (c *Connector) UnmarshalJSON(b []byte) error {
|
|
|
|
|
|
|
|
|
|
Config json.RawMessage `json:"config"` |
|
|
|
|
} |
|
|
|
|
if err := json.Unmarshal(b, &conn); err != nil { |
|
|
|
|
if err := configUnmarshaller(b, &conn); err != nil { |
|
|
|
|
return fmt.Errorf("parse connector: %v", err) |
|
|
|
|
} |
|
|
|
|
f, ok := server.ConnectorsConfig[conn.Type] |
|
|
|
|
@ -475,7 +485,7 @@ func (c *Connector) UnmarshalJSON(b []byte) error {
|
|
|
|
|
data := []byte(conn.Config) |
|
|
|
|
if featureflags.ExpandEnv.Enabled() { |
|
|
|
|
var rawMap map[string]interface{} |
|
|
|
|
if err := json.Unmarshal(conn.Config, &rawMap); err != nil { |
|
|
|
|
if err := configUnmarshaller(conn.Config, &rawMap); err != nil { |
|
|
|
|
return fmt.Errorf("unmarshal config for env expansion: %v", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -492,7 +502,7 @@ func (c *Connector) UnmarshalJSON(b []byte) error {
|
|
|
|
|
data = expandedData |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if err := json.Unmarshal(data, connConfig); err != nil { |
|
|
|
|
if err := configUnmarshaller(data, connConfig); err != nil { |
|
|
|
|
return fmt.Errorf("parse connector config: %v", err) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|