middleware

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 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 InitLogger

func InitLogger(logger *logrus.Logger)

func InitWithManualKey added in v0.0.51

func InitWithManualKey(randomSeed string)

func InitWithRandomKey added in v0.0.51

func InitWithRandomKey()

func Perm

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

Middleware for checking if a user has permission to access given resources The permissions to check is given as second or more arguments

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