middleware

package
v0.0.0-...-386a0b5 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package middleware is responsible for the definition/implementation of middleware functionality. This package will also handle maintaining request Context and Session.

Index

Constants

This section is empty.

Variables

View Source
var CSRFExemptPrefixes = []string{
	"/api",
}

Functions

func CSRFExceptions

func CSRFExceptions(handler http.Handler) http.HandlerFunc

func GetContext

func GetContext(handler http.Handler) http.HandlerFunc

GetContext wraps each request in a function which fills in the context for a given request. This includes setting the User and Session keys and values as necessary for use in later functions.

func JSONError

func JSONError(w http.ResponseWriter, c int, m string)

JSONError returns an error in JSON format with the given status code and message

func RequireAPIKey

func RequireAPIKey(handler http.Handler) http.HandlerFunc

func RequireIP

func RequireIP(ip string) func(http.Handler) http.HandlerFunc

func RequireLimitedAccessKey

func RequireLimitedAccessKey(handler http.Handler) http.HandlerFunc

func RequireLogin

func RequireLogin(handler http.Handler) http.HandlerFunc

RequireLogin is a simple middleware which checks to see if the user is currently logged in. If not, the function returns a 302 redirect to the login page.

func RequireRoles

func RequireRoles(rids []int64) func(http.Handler) http.HandlerFunc

RequireRoles enforces user role id to be one among the given role ids

func SSO

func SSO(handler http.Handler) http.HandlerFunc

SSO handles user authentication via encrypted CHOCOLATECHIPSSL cookie. If an email address extracted from such cookie belongs to an existing user then a session is created for that user.

Types

This section is empty.

Jump to

Keyboard shortcuts

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