middleware

package
v0.0.26-beta-rc.4 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func ApiAuth

func ApiAuth(handler http.HandlerFunc) http.HandlerFunc

func Auth

func Auth(handler http.HandlerFunc) http.HandlerFunc

Checks if a user is already logged in (session) If not, it checks for a url query `username=x&password=y` in order to authenticate the user If both methods fail, the user is redirected to `/login`

func GetUserFromCurrentSession

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

Parses the session and returns the currently logged in user If no user is logged in but is trying to authenticate with URL-queries, this function will call `getUserFromQuery` internally in order to get the username

func Init

func Init(useRandomSeed bool)

func InitLogger

func InitLogger(logger *logrus.Logger)

func Perm

func Perm(handler http.HandlerFunc, permissionToCheck database.PermissionType) http.HandlerFunc

Middleware for checking if a user has permission to access a given route The permission to check is given as a second argument as a string Make sure that the permission to check exists before checking it here

func Res

func Res(w http.ResponseWriter, res Response)

Types

type Response

type Response struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Error   string `json:"error"`
	Time    string `json:"time"`
}

Jump to

Keyboard shortcuts

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