Fix parsing openid config when using a json config file

(Cherry-picked from 570d146b21)
This commit is contained in:
kolaente 2021-06-09 21:56:17 +02:00
parent e837c2a003
commit 65ac7b1fc7
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -44,7 +44,18 @@ func GetAllProviders() (providers []*Provider, err error) {
rawProvider := rawProviders.([]interface{}) rawProvider := rawProviders.([]interface{})
for _, p := range rawProvider { for _, p := range rawProvider {
pi := p.(map[interface{}]interface{}) var pi map[string]interface{}
var is bool
pi, is = p.(map[string]interface{})
// JSON config is a map[string]interface{}, other providers are not. Under the hood they are all strings so
// it is save to cast.
if !is {
pis := p.(map[interface{}]interface{})
pi = make(map[string]interface{}, len(pis))
for i, s := range pis {
pi[i.(string)] = s
}
}
provider, err := getProviderFromMap(pi) provider, err := getProviderFromMap(pi)
if err != nil { if err != nil {
@ -94,7 +105,7 @@ func getKeyFromName(name string) string {
return reg.ReplaceAllString(strings.ToLower(name), "") return reg.ReplaceAllString(strings.ToLower(name), "")
} }
func getProviderFromMap(pi map[interface{}]interface{}) (*Provider, error) { func getProviderFromMap(pi map[string]interface{}) (*Provider, error) {
name, is := pi["name"].(string) name, is := pi["name"].(string)
if !is { if !is {
return nil, nil return nil, nil