http

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ACL

func ACL(next http.HandlerFunc, requireSuperOrAdmin, requireVerified, requireLoggedIn bool) http.HandlerFunc

ACL returns a middleware that must be used inside of an Auth middleware for checking user roles. The SuperOrAdmin requirement will be satisfied by any user who is either a SuperAdmin or a realm Admin.

func Auth

func Auth(next http.Handler, secret string) http.Handler

Auth returns a middleware used for jwt authentication.

func CORS

func CORS(next http.Handler, origin string) http.Handler

CORS is a middleware for setting Cross Origin Resource Sharing headers.

func Error

func Error(w http.ResponseWriter, httpCode int)

Error sets the specified HTTP status code.

func GetRealmID

func GetRealmID(r *http.Request) (int64, error)

GetRealmID retrieves the ID of the user's realm from the http context.

func GetRoles

func GetRoles(r *http.Request) store.Roles

GetRoles retrieves the roles from the http context.

func GetSubject

func GetSubject(r *http.Request) (int64, error)

GetSubject retrieves the subject (user id) from the http context.

func LimitBody

func LimitBody(next http.Handler) http.Handler

LimitBody is middleware to protect the server from requests containing massive amounts of data.

func Log

func Log(next http.Handler, l *logrus.Logger) http.HandlerFunc

Log logs information about incoming HTTP requests.

func Respond

func Respond(w http.ResponseWriter, data interface{}, httpCode int)

Respond encodes the data and ResponseError to JSON and responds with it and the http code. If the encoding fails, sets an InternalServerError.

Types

type Claims

type Claims struct {
	Roles   store.Roles `json:"peregrineRoles"`
	RealmID int64       `json:"peregrineRealm"`
	jwt.StandardClaims
}

Claims holds the standard jwt claims, peregrine roles, and realm id.

type RefreshClaims

type RefreshClaims struct {
	PasswordChanged store.UnixTime `json:"peregrinePasswordChanged"`
	jwt.StandardClaims
}

RefreshClaims holds the standard jwt claims plus

Jump to

Keyboard shortcuts

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