Package auth implements the authentication in use for gophish.
const APIKeyLength = 32
APIKeyLength is the length of Gophish API keys
const MinPasswordLength = 8
MinPasswordLength is the minimum number of characters required in a password
ErrEmptyPassword is thrown when a user provides a blank password to the register or change password functions
ErrInvalidPassword is thrown when a user provides an incorrect password.
ErrPasswordMismatch is thrown when a user provides a mismatching password and confirmation password.
ErrPasswordTooShort is thrown when a user provides a password that is less than MinPasswordLength
ErrReusedPassword is thrown when a user attempts to change their password to the existing password
CheckPasswordPolicy ensures the provided password is valid according to our password policy.
The current password policy is simply a minimum of 8 characters, though this may change in the future (see #1538).
GeneratePasswordHash returns the bcrypt hash for the provided password using the default bcrypt cost.
GenerateSecureKey returns the hex representation of key generated from n random bytes
ValidatePassword validates that the provided password matches the provided bcrypt hash.
ValidatePasswordChange validates that the new password matches the configured password policy, that the new password and confirmation password match.
Note that this assumes the current password has been confirmed by the caller.
If all of the provided data is valid, then the hash of the new password is returned.