auth

package
v0.0.0-...-8aa12d4 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateUser

func CreateUser(username, password string) error

CreateUser saves a new user with the given password. The user's password is processed by SHA-512 then bcrypt.

func GenerateTag

func GenerateTag() string

func GetOrSetTag

func GetOrSetTag(w http.ResponseWriter, r *http.Request) string

GetOrSetTag will get an existing tag or create a new one

func GetSavedSession

func GetSavedSession(sessionKey string) (s *data.Session, err error)

GetSavedSession retrieves a session from the database

func GetSession

func GetSession(r *http.Request) (*data.Session, error)

GetSession searches the request's cookies for the user's session

func GetTag

func GetTag(r *http.Request) string

GetTag will get an existing tag

func Logout

func Logout(w http.ResponseWriter, r *http.Request, s *data.Session)

Logout clears the user's session cookie from the browser

func MustGetSession

func MustGetSession(r *http.Request) (*data.Session, error)

MustGetSession returns an error if GetSession does not find a user session

func NewSession

func NewSession(user *data.User, expires time.Time, ipAddress, userAgent string) (*data.Session, error)

NewSession generates a new session for the user

func SetSessionCookie

func SetSessionCookie(w http.ResponseWriter, r *http.Request, u *data.User, rememberMe bool) error

SetSessionCookie saves the session cookie to the user's browser

func SetTagCookie

func SetTagCookie(w http.ResponseWriter, r *http.Request) string

SetTagCookie assigns the browser a unique ID that persists across connections

func UserLogin

func UserLogin(username, password string) (*data.User, error)

UserLogin validates user credentials

Types

This section is empty.

Jump to

Keyboard shortcuts

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