Documentation ¶
Overview ¶
Package jsonwebtoken is a set of helper functions for encoding, signing, decoding and verifying JSON web tokens built on top of https://github.com/dgrijalva/jwt-go with a smaller and simpler API.
Install latest version with:
go get -u github.com/montanaflynn/jsonwebtoken
Index ¶
- Variables
- func DecodeECDSA(tokenString string, key *ecdsa.PublicKey) (jwt.MapClaims, error)
- func DecodeECDSAFromPemFile(tokenString string, file string) (jwt.MapClaims, error)
- func DecodeHMAC(tokenString string, key []byte) (jwt.MapClaims, error)
- func DecodeRSA(tokenString string, key *rsa.PublicKey) (jwt.MapClaims, error)
- func DecodeRSAFromPemFile(tokenString string, filePath string) (jwt.MapClaims, error)
- func EncodeECDSA(claims jwt.Claims, key *ecdsa.PrivateKey) (string, error)
- func EncodeECDSAFromPemFile(claims jwt.Claims, file string) (string, error)
- func EncodeHMAC(claims jwt.Claims, key []byte) (string, error)
- func EncodeRSA(claims jwt.Claims, key *rsa.PrivateKey) (string, error)
- func EncodeRSAFromPemFile(claims jwt.Claims, filePath string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTokenCouldNotBeParsed is returned when a token could not be parsed ErrTokenCouldNotBeParsed = errors.New("token could not be parsed") // ErrTokenIsNotJSONWebToken is returned when a token is not a json web token ErrTokenIsNotJSONWebToken = errors.New("token is not a json web token") // ErrTokenIsNotValid is returned when a token is not valid ErrTokenIsNotValid = errors.New("token is not valid") // ErrTokenIsNotActiveYet is returned when a token is not active yet ErrTokenIsNotActiveYet = errors.New("token is not active yet") // ErrTokenIsExpired is returned when a token is expired ErrTokenIsExpired = errors.New("token is expired") // ErrTokenClaimsCannotBeAsserted is returned when token claims cannot be asserted ErrTokenClaimsCannotBeAsserted = errors.New("token claims cannot be asserted") )
Functions ¶
func DecodeECDSA ¶
DecodeECDSA decodes and verifies a json web token using an ECDSA public key and returns a map of the claims held inside the token
func DecodeECDSAFromPemFile ¶
DecodeECDSAFromPemFile decodes and verifies a json web token using an ECDSA public key pem container formatted file path and returns a map of the claims held inside the token
func DecodeHMAC ¶
DecodeHMAC decodes and verifies a json web token using an HMAC secret key and returns a map of the claims held inside the token.
func DecodeRSA ¶
DecodeRSA decodes and verifies a json web token using an RSA public key and returns a map of the claims held inside the token.
func DecodeRSAFromPemFile ¶
DecodeRSAFromPemFile decodes and verifies a json web token using an RSA public key pem container formatted file path and returns a map of the claims held inside the token.
func EncodeECDSA ¶
EncodeECDSA encodes and signs a json web token using the claims that the json web token should include and an an ECDSA private key.
func EncodeECDSAFromPemFile ¶
EncodeECDSAFromPemFile encodes and signs a json web token using the claims that the json web token should include and an ECDSA private key pem container formatted file.
func EncodeHMAC ¶
EncodeHMAC encodes and signs a json web token using the claims that the json web token should include and an HMAC secret key.
Types ¶
This section is empty.