Documentation
¶
Overview ¶
auth/validation/password.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrPasswordTooShort = errors.New("password is too short") ErrPasswordTooLong = errors.New("password is too long") ErrMissingUppercase = errors.New("password must contain at least one uppercase letter") ErrMissingLowercase = errors.New("password must contain at least one lowercase letter") ErrMissingNumber = errors.New("password must contain at least one number") ErrMissingSpecial = errors.New("password must contain at least one special character") ErrContainsUsername = errors.New("password cannot contain the username") ErrCommonPassword = errors.New("password is too common") ErrConsecutiveChars = errors.New("password contains consecutive repeated characters") ErrSequentialChars = errors.New("password contains sequential characters") )
Functions ¶
This section is empty.
Types ¶
type PasswordPolicy ¶
type PasswordPolicy struct {
MinLength int
MaxLength int
RequireUppercase bool
RequireLowercase bool
RequireNumbers bool
RequireSpecial bool
MaxRepeatingChars int
PreventSequential bool
PreventUsernamePart bool
}
func DefaultPasswordPolicy ¶
func DefaultPasswordPolicy() PasswordPolicy
DefaultPasswordPolicy returns a recommended password policy
type PasswordValidator ¶
type PasswordValidator struct {
// contains filtered or unexported fields
}
func NewPasswordValidator ¶
func NewPasswordValidator(policy PasswordPolicy) *PasswordValidator
func (*PasswordValidator) ValidatePassword ¶
func (v *PasswordValidator) ValidatePassword(password string, username string) error
Click to show internal directories.
Click to hide internal directories.