mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
b4e570358e
* build: include major in go.mod module directive * fix: xflags * revert: cobra changes * fix: mock doc
27 lines
752 B
Go
27 lines
752 B
Go
package validator
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/authelia/authelia/v4/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"))
|
|
}
|
|
}
|