auth

package
v0.0.0-...-062e030 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRetrievingSessionToken = errors.New("Could not retrieve a session cookie")
	ErrInvalidSessionToken    = errors.New("Session token is invalid")
)
View Source
var ErrLoginAttemptUnsuccessful = errors.New("Login attempt unsuccessful")

Functions

func Authenticate

func Authenticate(r *http.Request) (string, error)

Authenticate checks if the session token belongs to a user

func GenerateHashedPassword

func GenerateHashedPassword(password string) string

GenerateHashedPassword creates a new hashed password

func GenerateSessionToken

func GenerateSessionToken() string

GenerateSessionToken creates a random session token

func IsPasswordCorrect

func IsPasswordCorrect(password string, hashedPassword string) bool

IsPasswordCorrect compares a password with a hashedPassword

func LogOut

func LogOut(r *http.Request)

func SignIn

func SignIn(username string, password string) (db.SessionIdentity, error)

SignIn creates a SessionIdentity in the db if the password is correct for the username

func SignUp

func SignUp(username string, password string) error

SignUp stores a user in the db with the password in hashed form

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳