auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MinPassLength is the minimum length allowable for passwords
	MinPassLength = 8
	// MaxPassLength is the maxiumum length allowable for passwords
	MaxPassLength = 50

	// MinUsernameLength is the minimum length allowable for usernames
	MinUsernameLength = 3
	// MaxUsernameLength is the maxiumum length allowable for usernames
	MaxUsernameLength = 15

	// MinPasswordLength is the minimum length allowable for passwords
	MinPasswordLength = 8
)

Variables

This section is empty.

Functions

func Authorize

func Authorize(headers http.Header, secret string) (string, string, error)

Authorize takes the headers and returns the username of the user if the token is valid

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash checks a password hash

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes a password securely

func MakeToken

func MakeToken(domain, username, secret string, nowUTC time.Time, expiresIn time.Duration) (string, error)

MakeToken makes a new jwt token for a user

func ValidatePassword

func ValidatePassword(password string) bool

ValidatePassword returns true if string is a valid password format At least one upper case English letter At least one lower case English letter At least one digit At least one special character Minimum eight in length

func ValidateToken

func ValidateToken(tokenString, secret string, nowUTC time.Time) (string, string, error)

ValidateToken returns the username and domain associate with the token if it is valid

Types

type Claims

type Claims struct {
	Domain   string `json:"domain"`
	Username string `json:"username"`
	jwt.StandardClaims
}

Claims for JWT

Jump to

Keyboard shortcuts

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