Documentation
¶
Index ¶
- Constants
- func WithJWTMapClaims(signingKey any) jwtParserOpt
- func WithKeyFunc(keyFunc jwt.Keyfunc) jwtParserOpt
- func WithNewClaimsFunc(newClaimsFunc func(context.Context) jwt.Claims) jwtParserOpt
- func WithSigningKey(signingKey any) jwtParserOpt
- func WithSigningKeys(signingKeys map[string]any) jwtParserOpt
- func WithSigningMethod(signingMethod string) jwtParserOpt
- type JwtParser
Constants ¶
View Source
const (
// AlgorithmHS256 is token signing algorithm
AlgorithmHS256 = "HS256"
)
Variables ¶
This section is empty.
Functions ¶
func WithJWTMapClaims ¶
func WithJWTMapClaims(signingKey any) jwtParserOpt
WithJWTMapClaims returns a jwtParser with default jwt.MapClaims and signingMethod
func WithKeyFunc ¶
func WithNewClaimsFunc ¶
WithNewClaimsFunc sets NewClaimsFunc. the newClaimsFunc must return a reference for json unmarshalling to work
func WithSigningKey ¶
func WithSigningKey(signingKey any) jwtParserOpt
func WithSigningKeys ¶
func WithSigningMethod ¶
func WithSigningMethod(signingMethod string) jwtParserOpt
Types ¶
type JwtParser ¶
type JwtParser struct {
// Signing key to validate token.
// This is one of the three options to provide a token validation key.
// The order of precedence is a user-defined KeyFunc, SigningKeys and SigningKey.
// Required if neither user-defined KeyFunc nor SigningKeys is provided.
SigningKey any
// KeyFunc defines a user-defined function that supplies the public key for a token validation.
// The function shall take care of verifying the signing algorithm and selecting the proper key.
// A user-defined KeyFunc can be useful if tokens are issued by an external party.
// Used by default ParseTokenFunc implementation.
//
// When a user-defined KeyFunc is provided, SigningKey, SigningKeys, and SigningMethod are ignored.
// This is one of the three options to provide a token validation key.
// The order of precedence is a user-defined KeyFunc, SigningKeys and SigningKey.
// Required if neither SigningKeys nor SigningKey is provided.
// Default to an internal implementation verifying the signing algorithm and selecting the proper key.
KeyFunc jwt.Keyfunc
// Map of signing keys to validate token with kid field usage.
// This is one of the three options to provide a token validation key.
// The order of precedence is a user-defined KeyFunc, SigningKeys and SigningKey.
// Required if neither user-defined KeyFunc nor SigningKey is provided.
SigningKeys map[string]any
// Signing method used to check the token's signing algorithm.
// Optional. Default value HS256.
SigningMethod string
// NewClaimsFunc is used during parsing the token, it must return a reference for json unmarshalling to work
// Default to function returning jwt.MapClaims
NewClaimsFunc func(c context.Context) jwt.Claims
}
func NewJwtParser ¶
Click to show internal directories.
Click to hide internal directories.