mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
e56690c2df
This ensures keys that exist in slices are validated.
37 lines
572 B
Go
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
|
|
}
|