Documentation ¶
Index ¶
- func GetToken(claims jwt.Claims, alg string) (string, error)
- func GetTokenHS256(claims jwt.Claims) (string, error)
- func GetTokenRS256(claims jwt.Claims) (string, error)
- func ValidateToken(tokenString string) (*jwt.Token, error)
- func VerifyEmail(token *jwt.Token) error
- func VerifyJWKS(tokenString string, jwksURL string) (*jwt.Token, error)
- func VerifyManualHS256(tokenString string) error
- type SimpleClaims
- type TokenGetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetToken ¶
GetToken accepts a claims object and signs it with the algorithm provided via the alg field.
func GetTokenHS256 ¶
GetTokenHS256 returns a JWT token created from the provided claims object
func GetTokenRS256 ¶
GetTokenRS256 returns a JWT token created from the provided claims object
func ValidateToken ¶
ValidateToken parses a JWT token, checks it for validity and returns a `*jwt.Token` object
func VerifyEmail ¶
VerifyEmail checks if token contains an "email" field and also an "email_verified" field (which is either `true` or `"true"`). I wrote this to checking that I am getting a token from a verified logged-in user from Auth0 but left it here anyway.
func VerifyJWKS ¶
VerifyJWKS to verify token via JWKS
func VerifyManualHS256 ¶
VerifyManualHS256 manually verifies that a JWT token is valid and returns the body in a DummyJSONClaims object This assumes that the token is a HS256 token
Types ¶
type SimpleClaims ¶
type SimpleClaims map[string]interface{}
SimpleClaims lets us parse random JSON strings as a `map[string]interface{}` and have the resultant JSON satisfy the `jwt.Claims` interface
func ParseClaims ¶
func ParseClaims(tokenString string) (claims SimpleClaims, err error)
ParseClaims parses the claims portion of a JWT token
func (*SimpleClaims) FromBytes ¶
func (c *SimpleClaims) FromBytes(b []byte) error
FromBytes loads a SimpleClaims object from `[]byte`
func (*SimpleClaims) FromReader ¶
func (c *SimpleClaims) FromReader(r io.Reader) error
FromReader loads a SimpleClaims object from an `io.Reader`
func (SimpleClaims) Valid ¶
func (c SimpleClaims) Valid() error
Valid lets SimpleClaims implement `jwt.Claims`