gophish: Index | Files

package auth

import ""

Package auth implements the authentication in use for gophish.


Package Files

auth.go doc.go


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


var ErrEmptyPassword = errors.New("No password provided")

ErrEmptyPassword is thrown when a user provides a blank password to the register or change password functions

var ErrInvalidPassword = errors.New("Invalid Password")

ErrInvalidPassword is thrown when a user provides an incorrect password.

var ErrPasswordMismatch = errors.New("Passwords do not match")

ErrPasswordMismatch is thrown when a user provides a mismatching password and confirmation password.

var ErrPasswordTooShort = fmt.Errorf("Password must be at least %d characters", MinPasswordLength)

ErrPasswordTooShort is thrown when a user provides a password that is less than MinPasswordLength

var ErrReusedPassword = errors.New("Cannot reuse existing password")

ErrReusedPassword is thrown when a user attempts to change their password to the existing password

func CheckPasswordPolicy Uses

func CheckPasswordPolicy(password string) error

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).

func GeneratePasswordHash Uses

func GeneratePasswordHash(password string) (string, error)

GeneratePasswordHash returns the bcrypt hash for the provided password using the default bcrypt cost.

func GenerateSecureKey Uses

func GenerateSecureKey(n int) string

GenerateSecureKey returns the hex representation of key generated from n random bytes

func ValidatePassword Uses

func ValidatePassword(password string, hash string) error

ValidatePassword validates that the provided password matches the provided bcrypt hash.

func ValidatePasswordChange Uses

func ValidatePasswordChange(currentHash, newPassword, confirmPassword string) (string, error)

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.

Package auth imports 5 packages (graph) and is imported by 37 packages. Updated 2020-06-22. Refresh now. Tools for package owners.