Documentation ¶
Overview ¶
token package imnplements common methods for handling tokens.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct { errors.AuthErrCheck // contains filtered or unexported fields }
JWT Handler handles JWT tokens with the help of the github.com/dgrijalva/jwt-go library. Call NewHandler() to get the correct instance of this struct.
func NewHandler ¶
NewHandler constructs a Handler struct for handling JWT tokens.
func (*Handler) Generate ¶
Generate generates a JWT token based on provided claims using jwt.SigningMethodHS256 to sign the token string. jwt.StandardClaims is a good starting point for a claims struct and can be extended to implement the jwt.Claims interface.
func (*Handler) Validate ¶
Validate validates a token that was generated using jwt.SigningMethodHS256 to sign the token string.
the error - err - returned will evaluate (*Handler).IsAuthError(err) to true if the token is invalid, otherwise any other error is returned if the parameters are invalid e.g. nil claims parameter.
The claims parameter should be a pointer to the struct to which the (valid) token is unmarshalled into.
The returned *jwt.Token provides standard information on the token.