Back to

Package auth

Latest Go to latest

The latest major version is .

Published: Apr 13, 2020 | License: AGPL-3.0 | Module:


Package auth implements the authentication functions for the server.


func Authenticate

func Authenticate(db db.DBContext, c echo.Context) (*models.User, error)

Authenticate tries to resolve an authentication from the context. Might return a nil user with a nil error.

func AuthenticateAdmin

func AuthenticateAdmin(c echo.Context) (bool, error)

AuthenticateAdmin returns whether the context has admin panel access.

func CheckPassword

func CheckPassword(raw, hashed string) (bool, error)

CheckPassword returns whether the raw password matches the hashed password.

func MustAdmin

func MustAdmin(h echo.HandlerFunc) echo.HandlerFunc

MustAdmin is a middleware that ensures admin access.

func MustAuth

func MustAuth(db *db.DB) echo.MiddlewareFunc

MustAuth returns the middleware that redirects to /login if authentication is not found.

func PasswordHash

func PasswordHash(raw string) ([]byte, error)

PasswordHash hashes a raw string into a hashed password.

func Remove

func Remove(c echo.Context) error

Remove removes the authentication cookie.

func RemoveAdmin

func RemoveAdmin(c echo.Context) error

RemoveAdmin removes the admin cookie session.

func SaveAdmin

func SaveAdmin(key string, c echo.Context) error

SaveAdmin saves the admin cookie.

func Store

func Store(u *models.User, timeout time.Duration, c echo.Context) error

Store stores the user as a cookie.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier