mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
c1ac25a15b
* [FEATURE] Config Validation * check configuration for invalid keys on startup * allow users to manually trigger all configuration validation on a file using a cmd * setup all defaults in config template and run tests against it to prevent accidents * use tests to check bad configuration values are caught * use tests to check old configuration values are caught * add tests for specific key errors * resolve merge conflicts * nolint prealloc for test
30 lines
639 B
Go
30 lines
639 B
Go
package validator
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/authelia/authelia/internal/configuration/schema"
|
|
"github.com/authelia/authelia/internal/utils"
|
|
)
|
|
|
|
func ValidateKeys(validator *schema.StructValidator, keys []string) {
|
|
var errStrings []string
|
|
for _, key := range keys {
|
|
if utils.IsStringInSlice(key, validKeys) {
|
|
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))
|
|
}
|
|
}
|