Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
func Middleware(config Config) gin.HandlerFunc
Middleware Analyses http request, parse existing JWT tokens and set the claim map to gin.Context according to configuration.Middleware The jwt token claims can be later checked by request handlers with "c.GetString(...)"
Types ¶
type Config ¶
type Config struct { //SkipPathRegex Request paths (as in gin.Context.FullPath()) that matches this regex won't be processed SkipPathRegex string //FromBearer Name of HTTP Header to load JWT token from. Header value should be prefixed by "Bearer " FromBearer string //FromCookie Name of the cookie to load JWT token from FromCookie string //FromQuery Name of request query param to load JWT token from FromQuery string //JWTSigningMethod JWT signing method. One of HS*, ES* or RS* JWTSigningMethod string //JWTVerifyKeyFile JWT signing file path (if ES or RS, must contain a public key) JWTVerifyKeyFile string //JWTContextName Name of the context property to place JWT claims after token is parsed and validated. This is a replication of the flat claims that are set to the root of the gin.Context. defaults to 'jwt' JWTContextName string //RequiredIssuer Required 'iss' value in token. Not verified if empty. RequiredIssuer string //RequiredType Required 'typ' value in token. Not verified if empty RequiredType string //RequiredClaims Required values in JWT token claims. No effect if empty. RequiredClaims map[string]string // contains filtered or unexported fields }
Config configuration properties for JWT Parser
Click to show internal directories.
Click to hide internal directories.