middleware

package
v0.0.0-...-44dcfa3 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleClaim = "roles"
	SubClaim  = "sub"
)
View Source
const RequestID = "x-request-id"

Variables

This section is empty.

Functions

func JWTMiddlewareExtract

func JWTMiddlewareExtract() gin.HandlerFunc

JWTExtract Extracts the JWT from the header and place the role claim and the sub claim as part of the context to be used latter.

func RBACMiddleware

func RBACMiddleware(allowedRoles ...string) gin.HandlerFunc

RBACMiddleware Validates if a given token has the needed permissions to continue the request. It accepts a list of allowed roles for that endpoint. If the user don't own the resource the role will determine if the user can access it or not. The path must have an owner parameter.

func RequestIDMiddleware

func RequestIDMiddleware() gin.HandlerFunc

RequestIDMiddleware provides an ID to the request for traceback purposes.

func ResponseIDMiddleware

func ResponseIDMiddleware() gin.HandlerFunc

ResponseMiddleware sets the header with the request header.

Types

This section is empty.

Jump to

Keyboard shortcuts

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