2020-04-05 12:37:21 +00:00
|
|
|
package validator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2021-08-11 01:04:35 +00:00
|
|
|
"github.com/authelia/authelia/v4/internal/configuration/schema"
|
2020-04-05 12:37:21 +00:00
|
|
|
)
|
|
|
|
|
2020-04-20 21:03:38 +00:00
|
|
|
// ValidateRegulation validates and update regulator configuration.
|
2022-02-28 03:15:01 +00:00
|
|
|
func ValidateRegulation(config *schema.Configuration, validator *schema.StructValidator) {
|
2022-03-03 11:20:43 +00:00
|
|
|
if config.Regulation.FindTime <= 0 {
|
2022-02-28 03:15:01 +00:00
|
|
|
config.Regulation.FindTime = schema.DefaultRegulationConfiguration.FindTime // 2 min.
|
2020-04-05 12:37:21 +00:00
|
|
|
}
|
2020-05-05 19:35:32 +00:00
|
|
|
|
2022-03-03 11:20:43 +00:00
|
|
|
if config.Regulation.BanTime <= 0 {
|
2022-02-28 03:15:01 +00:00
|
|
|
config.Regulation.BanTime = schema.DefaultRegulationConfiguration.BanTime // 5 min.
|
2020-04-05 12:37:21 +00:00
|
|
|
}
|
2020-05-05 19:35:32 +00:00
|
|
|
|
2022-03-02 06:40:26 +00:00
|
|
|
if config.Regulation.FindTime > config.Regulation.BanTime {
|
2022-02-28 03:15:01 +00:00
|
|
|
validator.Push(fmt.Errorf(errFmtRegulationFindTimeGreaterThanBanTime))
|
2020-04-05 12:37:21 +00:00
|
|
|
}
|
|
|
|
}
|