mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
6276883f04
This enhances the existing time.Duration parser to allow multiple units, and implements a decode hook which can be used by koanf to decode string/integers into time.Durations as applicable.
23 lines
659 B
Go
23 lines
659 B
Go
package validator
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/authelia/authelia/v4/internal/configuration/schema"
|
|
)
|
|
|
|
// ValidateRegulation validates and update regulator configuration.
|
|
func ValidateRegulation(config *schema.Configuration, validator *schema.StructValidator) {
|
|
if config.Regulation.FindTime == 0 {
|
|
config.Regulation.FindTime = schema.DefaultRegulationConfiguration.FindTime // 2 min.
|
|
}
|
|
|
|
if config.Regulation.BanTime == 0 {
|
|
config.Regulation.BanTime = schema.DefaultRegulationConfiguration.BanTime // 5 min.
|
|
}
|
|
|
|
if config.Regulation.FindTime > config.Regulation.BanTime {
|
|
validator.Push(fmt.Errorf(errFmtRegulationFindTimeGreaterThanBanTime))
|
|
}
|
|
}
|