Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var HasPermission = func(up UserPermission) (bool, error) { permissions, err := getPermissions(up.Request) if err != nil { return false, err } return permissionPresent(permissions, up.Permission), nil }
HasPermission confirms the requester has the correct permission to complete the action.
View Source
var ValidUser = func(uv UserValidation) (int, error) { if matchingUser, err := matchingUser(uv.Request, uv.Identifier, uv.Key); err != nil { return http.StatusInternalServerError, err } else if !matchingUser { up := UserPermission{ Request: uv.Request, Permission: uv.Permission, } if hasPermission, err := HasPermission(up); err != nil { return http.StatusInternalServerError, err } else if !hasPermission { return http.StatusUnauthorized, errors.New("missing or invalid permissions") } } return 200, nil }
ValidUser confirms the requester is either making changes to their own data or has the correct permission to complete the action.
Functions ¶
func GetJwtMiddleware ¶
func GetJwtMiddleware(audience, issuer string) *jwtmiddleware.JWTMiddleware
GetJwtMiddleware returns the Auth0 middleware used to handle authorized endpoints.
Types ¶
type JSONWebKeys ¶
type JSONWebKeys struct { Kty string `json:"kty"` Kid string `json:"kid"` Use string `json:"use"` N string `json:"n"` E string `json:"e"` X5c []string `json:"x5c"` }
JSONWebKeys holds fields related to the JSON Web Key Set for this API.
type Jwks ¶
type Jwks struct {
Keys []JSONWebKeys `json:"keys"`
}
Jwks holds a list of json web keys.
type Response ¶
type Response struct {
Message string `json:"message"`
}
Response holds the response message.
type UserPermission ¶
UserPermission is the data used in HasPermission.
Click to show internal directories.
Click to hide internal directories.