Documentation ¶
Index ¶
Constants ¶
View Source
const ( // MinLength is the minimum number of characters a password MUST contain. MinLength = 10 // MaxLength is the maximum number of characters a password MUST contain. MaxLength = 64 )
Variables ¶
View Source
var ( // ErrPasswordWeak indicates the password does not meet our rules. ErrPasswordWeak = merry. New("password does not meet the requirements and is considered weak"). WithUserMessage("Password does not meet the requirements and is considered too weak.") // ErrPasswordLength indicates the password is not within the min and max // length requirement. ErrPasswordLength = merry. WithMessage(ErrPasswordWeak, fmt.Sprintf("password must be %d-%d characters long", MinLength, MaxLength)). WithUserMessage(fmt.Sprintf("Password must be %d-%d characters long.", MinLength, MaxLength)) // ErrPasswordContainsName indicates the password is not allowed because it // contains part or all of their name or username. ErrPasswordContainsName = merry. WithMessage(ErrPasswordWeak, "password cannot contain the first, last, and/or username"). WithUserMessage("Password cannot contain your any part of your name or username.") )
Functions ¶
func CheckPasswordRules ¶
CheckPasswordRules returns nil if the password meets all of the requirements. Otherwise, it returns an error describing which rule it currently violates.
Rules:
- Must be at between MinLength and MaxLength
TODO: Check against a list of common passwords - JZ TODO: Check this isn't equal to their current password? - JZ
func Hash ¶
Hash take a plaintext password and returns a securely hashed version.
Currently uses bcrypt ¶
Use this instead of a specific hashing algorithm so we can change which algorithm is used between versions.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.