auth

package
v0.0.0-...-ede1b7c Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const SessionCookieName = "HacksiteSession"

SessionCookieName is the name of the cookie

View Source
const SessionMaxAge = 900

SessionMaxAge is the cookie length in seconds

View Source
const SessionOfOneThousandYears = 31536000000

SessionMaxAge when RememberMe is true... 1000 years in seconds

View Source
const (
	// UnathorizedErrorMessage is used to determine if the error is because of unathorized account
	UnathorizedErrorMessage = "Account is invalid"
)

Variables

This section is empty.

Functions

func CreateSession

func CreateSession(username string) models.Session

CreateSession returns the session token to store in the cookie

func CreateSessionToken

func CreateSessionToken() string

CreateSessionToken generates a random session token

func GetCurrentAccountFromSession

func GetCurrentAccountFromSession(db database.Database, logger log.Logger, sesh models.Session) (models.Account, error)

GetCurrentAccountFromSession gets the account information for the session

func GetCurrentSession

func GetCurrentSession(db database.Database, logger log.Logger, r *http.Request) (models.Session, error)

GetCurrentSession reads the session cookie and grabs the session associated

func GetSaltedPassword

func GetSaltedPassword(password string, salt string) (string, error)

GetSaltedPassword returns the salted version of the password using the account's salt

func Login

func Login(db database.Database, username, password string) (models.Session, error)

Login will attempt to login the user and return a new session

func SaltPassword

func SaltPassword(password string) (string, string, error)

SaltPassword generates a salt, puts it into the password and returns the salt and the new password or an error

func SetCookie

func SetCookie(w http.ResponseWriter, name, token string, rememberMe bool)

SetCookie creates an http cookie and sets it in the response

Types

This section is empty.

Jump to

Keyboard shortcuts

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