Documentation ¶
Index ¶
Constants ¶
View Source
const DEFAULT_CONTEXT_KEY = "_JWT_TOKEN_"
Variables ¶
View Source
var ( // ErrMissingRealm indicates Realm name is required ErrMissingRealm = errors.New("realm is missing") ErrMissingSigningAlgorithm = errors.New("signing algorithm is missing") ErrMissingKeyFunction = errors.New("key function is missing") ErrContextNotHaveToken = errors.New("context not have token") // ErrForbidden when HTTP status 403 is given ErrForbidden = errors.New("you don't have permission to access this resource") // ErrForbidden when HTTP status 403 is given ErrNotSupportSigningAlgorithm = errors.New("this signing algorithm NOT support") // ErrExpiredToken indicates JWT token has expired. Can't refresh. ErrTokenInvalid = errors.New("token is invalid") // ErrEmptyAuthHeader can be thrown if authing with a HTTP header, the Auth header needs to be set ErrEmptyAuthHeader = errors.New("auth header is empty") // ErrInvalidAuthHeader indicates auth header is invalid, could for example have the wrong Realm name ErrInvalidAuthHeader = errors.New("auth header is invalid") // ErrEmptyQueryToken can be thrown if authing with URL Query, the query token variable is empty ErrEmptyQueryToken = errors.New("query token is empty") // ErrEmptyCookieToken can be thrown if authing with a cookie, the token cokie is empty ErrEmptyCookieToken = errors.New("cookie token is empty") // ErrInvalidSigningAlgorithm indicates signing algorithm is invalid, needs to be HS256, HS384, HS512, RS256, RS384 or RS512 ErrInvalidSigningAlgorithm = errors.New("invalid signing algorithm") // ErrInvalidKey indicates the the given public key is invalid ErrInvalidKey = errors.New("key invalid") )
Functions ¶
This section is empty.
Types ¶
type GeneratorConfig ¶
type JwtGenerator ¶
type JwtGenerator struct {
// contains filtered or unexported fields
}
func NewGinJwtGenerator ¶
func NewGinJwtGenerator(config GeneratorConfig) (*JwtGenerator, error)
func (*JwtGenerator) GenerateJwt ¶
type JwtMiddleware ¶
type JwtMiddleware struct {
// contains filtered or unexported fields
}
func NewGinJwtMiddleware ¶
func NewGinJwtMiddleware(config MiddlewareConfig) (*JwtMiddleware, error)
func (*JwtMiddleware) ExtractToken ¶
func (m *JwtMiddleware) ExtractToken(ctx *gin.Context) (*jwt.Token, error)
func (*JwtMiddleware) Handler ¶
func (m *JwtMiddleware) Handler(ctx *gin.Context)
Click to show internal directories.
Click to hide internal directories.