authelia/internal/configuration/koanf_util.go
James Elliott e56690c2df
refactor(configuration): ensure all keys are validated (#3208)
This ensures keys that exist in slices are validated.
2022-04-16 20:48:07 +10:00

37 lines
572 B
Go

package configuration
import (
"fmt"
"github.com/knadh/koanf"
"github.com/authelia/authelia/v4/internal/utils"
)
func getAllKoanfKeys(ko *koanf.Koanf) (keys []string) {
keys = ko.Keys()
for key, value := range ko.All() {
slc, ok := value.([]interface{})
if !ok {
continue
}
for _, item := range slc {
m, mok := item.(map[string]interface{})
if !mok {
continue
}
for k := range m {
full := fmt.Sprintf("%s[].%s", key, k)
if !utils.IsStringInSlice(full, keys) {
keys = append(keys, full)
}
}
}
}
return keys
}