mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
cc4f47f21c
This removes the deprecated options from 4.25. This includes the LDAP filters which allow {0} or {1} placeholders. The new aliases are documented. Additionally it refactors the keys validator to use uniform messages for most replaced keys.
42 lines
872 B
Go
42 lines
872 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 newKey, ok := replacedKeys[key]; ok {
|
|
validator.Push(fmt.Errorf(errFmtReplacedConfigurationKey, key, newKey))
|
|
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))
|
|
}
|
|
}
|