Documentation ¶
Index ¶
- Variables
- func Authenticator(next http.Handler) http.Handler
- func EpochNow() int64
- func ExpireIn(tm time.Duration) int64
- func FromContext(ctx context.Context) (*jwt.Token, jwt.MapClaims, error)
- func NewContext(ctx context.Context, t *jwt.Token, err error) context.Context
- func SetExpiryIn(claims jwt.MapClaims, tm time.Duration)
- func SetIssuedNow(claims jwt.MapClaims)
- func TokenFromHeader(r *http.Request) string
- func Verifier(ja *JWTAuth) func(http.Handler) http.Handler
- func Verify(ja *JWTAuth, findTokenFns ...func(r *http.Request) string) func(http.Handler) http.Handler
- func VerifyRequest(ja *JWTAuth, r *http.Request, findTokenFns ...func(r *http.Request) string) (*jwt.Token, error)
- type JWTAuth
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TokenCtxKey = &contextKey{"Token"} ErrorCtxKey = &contextKey{"Error"} )
View Source
var ( ErrExpired = errors.New("jwtauth: token is expired") ErrNBFInvalid = errors.New("jwtauth: token nbf validation failed") ErrIATInvalid = errors.New("jwtauth: token iat validation failed") ErrNoTokenFound = errors.New("jwtauth: no token found") ErrAlgoInvalid = errors.New("jwtauth: algorithm mismatch") )
Functions ¶
func EpochNow ¶
func EpochNow() int64
EpochNow is a helper function that returns the NumericDate time value used by the spec
func ExpireIn ¶
ExpireIn is a helper function to return calculated time in the future for "exp" claim
func FromContext ¶
func SetExpiryIn ¶
Set expiry ("exp") in the claims to some duration from the present time
func SetIssuedNow ¶
func SetIssuedNow(claims jwt.MapClaims)
Set issued at ("iat") to present time in the claims
func TokenFromHeader ¶
TokenFromHeader tries to retreive the token string from the "Authorization" reqeust header: "Authorization: Token T".
Types ¶
type JWTAuth ¶
type JWTAuth struct {
// contains filtered or unexported fields
}
func New ¶
New creates a JWTAuth authenticator instance that provides middleware handlers and encoding/decoding functions for JWT signing.
func NewWithParser ¶
func NewWithParser(alg string, parser *jwt.Parser, signKey interface{}, verifyKey interface{}) *JWTAuth
NewWithParser is the same as New, except it supports custom parser settings introduced in jwt-go/v2.4.0.
Click to show internal directories.
Click to hide internal directories.