mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-10 17:13:40 +00:00
33 lines
826 B
Go
33 lines
826 B
Go
|
package model
|
||
|
|
||
|
import (
|
||
|
caos_errs "github.com/caos/zitadel/internal/errors"
|
||
|
"github.com/caos/zitadel/internal/eventstore/models"
|
||
|
"regexp"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
hasStringLowerCase = regexp.MustCompile(`[a-z]`).MatchString
|
||
|
hasStringUpperCase = regexp.MustCompile(`[A-Z]`).MatchString
|
||
|
hasNumber = regexp.MustCompile(`[0-9]`).MatchString
|
||
|
hasSymbol = regexp.MustCompile(`[^A-Za-z0-9]`).MatchString
|
||
|
)
|
||
|
|
||
|
type PasswordComplexityPolicy struct {
|
||
|
models.ObjectRoot
|
||
|
|
||
|
State PolicyState
|
||
|
MinLength uint64
|
||
|
HasLowercase bool
|
||
|
HasUppercase bool
|
||
|
HasNumber bool
|
||
|
HasSymbol bool
|
||
|
}
|
||
|
|
||
|
func (p *PasswordComplexityPolicy) IsValid() error {
|
||
|
if p.MinLength == 0 || p.MinLength > 72 {
|
||
|
return caos_errs.ThrowInvalidArgument(nil, "MODEL-Lsp0e", "Errors.User.PasswordComplexityPolicy.MinLengthNotAllowed")
|
||
|
}
|
||
|
return nil
|
||
|
}
|