Back to

Package jwt

Latest Go to latest

The latest major version is .

Published: Apr 15, 2020 | License: MIT | Module:



var (
	// ErrEmptyAuthHeader can be thrown if authing with a HTTP header, the Auth header needs to be set
	ErrEmptyAuthHeader = errors.New("middleware header is empty")

	// ErrInvalidAuthHeader indicates middleware header is invalid, could for example have the wrong Realm name
	ErrInvalidAuthHeader = errors.New("middleware header is invalid")

	ErrInvalidKeyPath = errors.New("middleware pub key path is invalid")

func GetToken

func GetToken(c *gin.Context) string

GetToken help to get the JWT token string

type JWTMiddleware

type JWTMiddleware struct {
	PubKeyPath string

	HeaderName   string
	HeaderPrefix string
	// contains filtered or unexported fields

func NewJWTValidationMiddleware

func NewJWTValidationMiddleware(jwtm *JWTMiddleware) (*JWTMiddleware, error)

func (*JWTMiddleware) GetClaimsFromJWT

func (jwtm *JWTMiddleware) GetClaimsFromJWT(c *gin.Context) (MapClaims, error)

GetClaimsFromJWT get claims from JWT token

func (*JWTMiddleware) TokenValidationMiddleware

func (jwtm *JWTMiddleware) TokenValidationMiddleware() gin.HandlerFunc

func (*JWTMiddleware) VerifyToken

func (jwtm *JWTMiddleware) VerifyToken(c *gin.Context) (*jwt.Token, error)

VerifyToken verifies the token is valid and signed with the correct key

type MapClaims

type MapClaims = map[string]interface{}

func ExtractClaims

func ExtractClaims(c *gin.Context) MapClaims

ExtractClaims help to extract the JWT claims

func ExtractClaimsFromToken

func ExtractClaimsFromToken(token *jwt.Token) MapClaims

ExtractClaimsFromToken help to extract the JWT claims from token

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier