mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
a44f0cf959
* fix: redis sentinel secret missing * refactor: use consts for authentication_backend.file.password errs * fix: unit test for new default port * test: cover additional misses * test: fix windows/linux specific test error * test: more windows specific tests * test: remove superfluous url.IsAbs * test: validator 100% coverage
37 lines
737 B
Go
37 lines
737 B
Go
package validator
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/authelia/authelia/internal/configuration/schema"
|
|
"github.com/authelia/authelia/internal/utils"
|
|
)
|
|
|
|
// ValidateKeys determines if a provided key is valid.
|
|
func ValidateKeys(validator *schema.StructValidator, keys []string) {
|
|
var errStrings []string
|
|
|
|
for _, key := range keys {
|
|
if utils.IsStringInSlice(key, validKeys) {
|
|
continue
|
|
}
|
|
|
|
if isSecretKey(key) {
|
|
continue
|
|
}
|
|
|
|
if err, ok := specificErrorKeys[key]; ok {
|
|
if !utils.IsStringInSlice(err, errStrings) {
|
|
errStrings = append(errStrings, err)
|
|
}
|
|
} else {
|
|
validator.Push(fmt.Errorf("config key not expected: %s", key))
|
|
}
|
|
}
|
|
|
|
for _, err := range errStrings {
|
|
validator.Push(errors.New(err))
|
|
}
|
|
}
|