Documentation ¶
Index ¶
Constants ¶
View Source
const ClaimsContext string = "claims"
Variables ¶
View Source
var ErrNoToken = errors.New("jwt: no token could be extracted and Options.RequireToken is true")
Functions ¶
func ExtractTokenFromHeader ¶
ExtractTokenFromHeader extracts a JWT out of the authorization header of an HTTP request
Types ¶
type ErrorHandlerFunc ¶
type ErrorHandlerFunc func(err error, w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ErrorHandlerFunc defines a function which is called if an error occured during the extraction of a token
type JWTHandler ¶
type JWTHandler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func NewHandler(Options Options) *JWTHandler
NewHandler creates a new instance of the JWT handler
func (JWTHandler) AuthRequired ¶
func (h JWTHandler) AuthRequired(c *gin.Context)
AuthRequired is a middleware for gin-gonic
type Options ¶
type Options struct { TokenExtractor TokenExtractorFunc ErrorHandler ErrorHandlerFunc JWTKeySupplier jwt.Keyfunc JWTClaims jwt.Claims RequireToken bool }
var DefaultOptions Options
type TokenExtractorFunc ¶
TokenExtractorFunc defines a function which extracts a token out of an HTTP request
func ExtractFromFirstAvailable ¶
func ExtractFromFirstAvailable(extractors ...TokenExtractorFunc) TokenExtractorFunc
ExtractFromFirstAvailable extracts the token out of the specified extractors. The first token that is found will be returned
func ExtractTokenFromCookie ¶
func ExtractTokenFromCookie(cookie string) TokenExtractorFunc
ExtractTokenFromCookie extracts a JWT out of an HTTP cookie
Click to show internal directories.
Click to hide internal directories.