Documentation
¶
Index ¶
- Variables
- func ApiAuth(handler http.HandlerFunc) http.HandlerFunc
- func Auth(handler http.HandlerFunc) http.HandlerFunc
- func GetUserFromCurrentSession(w http.ResponseWriter, r *http.Request) (string, error)
- func Init(useRandomSeed bool)
- func InitLogger(logger *logrus.Logger)
- func Perm(handler http.HandlerFunc, permissionToCheck database.PermissionType) http.HandlerFunc
- func Res(w http.ResponseWriter, res Response)
- type Response
Constants ¶
This section is empty.
Variables ¶
View Source
var Store *sessions.CookieStore
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 ¶
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 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 ¶
Click to show internal directories.
Click to hide internal directories.