mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
1600e0f7da
* [CI] Add wsl linter * Implement wsl recommendations Co-authored-by: Clément Michaud <clement.michaud34@gmail.com>
27 lines
749 B
Go
27 lines
749 B
Go
package validator
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/authelia/authelia/internal/configuration/schema"
|
|
)
|
|
|
|
// ValidateTOTP validates and update TOTP configuration.
|
|
func ValidateTOTP(configuration *schema.TOTPConfiguration, validator *schema.StructValidator) {
|
|
if configuration.Issuer == "" {
|
|
configuration.Issuer = schema.DefaultTOTPConfiguration.Issuer
|
|
}
|
|
|
|
if configuration.Period == 0 {
|
|
configuration.Period = schema.DefaultTOTPConfiguration.Period
|
|
} else if configuration.Period < 0 {
|
|
validator.Push(fmt.Errorf("TOTP Period must be 1 or more"))
|
|
}
|
|
|
|
if configuration.Skew == nil {
|
|
configuration.Skew = schema.DefaultTOTPConfiguration.Skew
|
|
} else if *configuration.Skew < 0 {
|
|
validator.Push(fmt.Errorf("TOTP Skew must be 0 or more"))
|
|
}
|
|
}
|