auth

package
v0.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2022 License: MIT Imports: 5 Imported by: 56

Documentation

Overview

Package auth implements the authentication in use for gophish.

Index

Constants

View Source
const APIKeyLength = 32

APIKeyLength is the length of Gophish API keys

View Source
const MinPasswordLength = 8

MinPasswordLength is the minimum number of characters required in a password

Variables

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

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

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

ErrInvalidPassword is thrown when a user provides an incorrect password.

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

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

View Source
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

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

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

Functions

func CheckPasswordPolicy added in v0.11.0

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 added in v0.11.0

func GeneratePasswordHash(password string) (string, error)

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

func GenerateSecureKey

func GenerateSecureKey(n int) string

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

func ValidatePassword added in v0.11.0

func ValidatePassword(password string, hash string) error

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

func ValidatePasswordChange added in v0.11.0

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL