Documentation ¶
Index ¶
- func ACL(next http.HandlerFunc, ...) http.HandlerFunc
- func Auth(next http.Handler, secret string) http.Handler
- func CORS(next http.Handler, origin string) http.Handler
- func Error(w http.ResponseWriter, httpCode int)
- func GetRealmID(r *http.Request) (int64, error)
- func GetRoles(r *http.Request) store.Roles
- func GetSubject(r *http.Request) (int64, error)
- func LimitBody(next http.Handler) http.Handler
- func Log(next http.Handler, l *logrus.Logger) http.HandlerFunc
- func Respond(w http.ResponseWriter, data interface{}, httpCode int)
- type Claims
- type RefreshClaims
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 Error ¶
func Error(w http.ResponseWriter, httpCode int)
Error sets the specified HTTP status code.
func GetRealmID ¶
GetRealmID retrieves the ID of the user's realm from the http context.
func GetSubject ¶
GetSubject retrieves the subject (user id) from the http context.
func LimitBody ¶
LimitBody is middleware to protect the server from requests containing massive amounts of data.
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