Documentation
¶
Index ¶
- Constants
- Variables
- func CheckPasswordComplexity(password string) (err error)
- func GenerateEmailChangeToken(email string, expirationDate time.Time) (string, error)
- func GenerateJWTToken(subjectUID uuid.UUID, audience string, payload map[string]interface{}) (tokenString string, tokenUID uuid.UUID, err error)
- func GenerateJWTTokenWithExpirationData(subjectUID uuid.UUID, audience string, payload map[string]interface{}, ...) (tokenString string, tokenUID uuid.UUID, err error)
- func GeneratePasswordResetToken(email string, expirationDate time.Time) (string, error)
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(s int) (string, error)
- func HashPassword(pepper string, password string, salt []byte) (hashedPassword []byte, hashedSalt []byte)
- func ParseToken(tokenString string) (claims map[string]interface{}, err error)
- func ValidatePassword(password string) (length, number, upper, lower, special bool)
Constants ¶
const MinPasswordLength = 8
MinPasswordLength is the minimum length of a password.
Variables ¶
var ErrCannotGenerateRandomBytes = errors.New("cannot generate random bytes")
ErrCannotGenerateRandomBytes is the error returned when we cannot generate a random string
var ErrCannotGenerateRandomString = errors.New("cannot generate random token")
ErrCannotGenerateRandomString is the error returned when we cannot generate a random string
var ErrLength = errors.New("password should have more than 8 characters.")
ErrLength is an error that is returned when the password is not 8 characters long
var ErrLowercase = errors.New("password should have a minimum of 1 lower case letter [a-z].")
ErrLowercase is an error that is returned when the password does not contain any lowercase characters
var ErrNoTokenPresent = errors.New("no token present")
ErrNoTokenPresent is returned when no token is present
var ErrNumeric = errors.New("password should have a minimum of 1 numeric character! e.g. 1,..,9,0.")
ErrNumeric is an error that is returned when the password does not contain any numeric characters
var ErrSpecial = errors.New("password should have a minimum of 1 special character: ~!@#$%^&*()-_+={}[]|:<>,./?...")
ErrSpecial is an error that is returned when the password does not contain any special characters
var ErrTokenNotValid = errors.New("token not valid")
ErrTokenNotValid is returned when the token is not valid
var ErrUppercase = errors.New("password should have a minimum of 1 upper case letter [A-Z].")
ErrUppercase is an error that is returned when the password does not contain any uppercase characters
Functions ¶
func CheckPasswordComplexity ¶
CheckPasswordComplexity checks if the user password matches the conditions
func GenerateEmailChangeToken ¶
GenerateEmailChangeToken generate a token to verify a new email address
func GenerateJWTToken ¶
func GenerateJWTToken(subjectUID uuid.UUID, audience string, payload map[string]interface{}) (tokenString string, tokenUID uuid.UUID, err error)
GenerateJWTToken generate token for as user and a payload
func GenerateJWTTokenWithExpirationData ¶
func GenerateJWTTokenWithExpirationData(subjectUID uuid.UUID, audience string, payload map[string]interface{}, utcExpirationDate time.Time) (tokenString string, tokenUID uuid.UUID, err error)
GenerateJWTTokenWithExpirationData generate token for as user and a payload with expiration date
func GeneratePasswordResetToken ¶
GeneratePasswordResetToken generate a password reset token with an expiration date
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomString ¶
GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func HashPassword ¶
func HashPassword(pepper string, password string, salt []byte) (hashedPassword []byte, hashedSalt []byte)
HashPassword hashes the users password and also generates a specific salt per user
func ParseToken ¶
ParseToken takes a string and extracts the token
func ValidatePassword ¶
ValidatePassword validates the user's password seven or more characters, special, ...
Types ¶
This section is empty.