auth/jwt: fix and add comments
Peter Bourgon
6 years ago
14 | 14 | // JWTTokenContextKey holds the key used to store a JWT Token in the |
15 | 15 | // context. |
16 | 16 | JWTTokenContextKey contextKey = "JWTToken" |
17 | // JWTClaimsContxtKey holds the key used to store the JWT Claims in the | |
17 | ||
18 | // JWTClaimsContextKey holds the key used to store the JWT Claims in the | |
18 | 19 | // context. |
19 | 20 | JWTClaimsContextKey contextKey = "JWTClaims" |
20 | 21 | ) |
23 | 24 | // ErrTokenContextMissing denotes a token was not passed into the parsing |
24 | 25 | // middleware's context. |
25 | 26 | ErrTokenContextMissing = errors.New("token up for parsing was not passed through the context") |
27 | ||
26 | 28 | // ErrTokenInvalid denotes a token was not able to be validated. |
27 | 29 | ErrTokenInvalid = errors.New("JWT Token was invalid") |
30 | ||
28 | 31 | // ErrTokenExpired denotes a token's expire header (exp) has since passed. |
29 | 32 | ErrTokenExpired = errors.New("JWT Token is expired") |
33 | ||
30 | 34 | // ErrTokenMalformed denotes a token was not formatted as a JWT token. |
31 | 35 | ErrTokenMalformed = errors.New("JWT Token is malformed") |
36 | ||
32 | 37 | // ErrTokenNotActive denotes a token's not before header (nbf) is in the |
33 | 38 | // future. |
34 | 39 | ErrTokenNotActive = errors.New("token is not valid yet") |
35 | // ErrUncesptedSigningMethod denotes a token was signed with an unexpected | |
40 | ||
41 | // ErrUnexpectedSigningMethod denotes a token was signed with an unexpected | |
36 | 42 | // signing method. |
37 | 43 | ErrUnexpectedSigningMethod = errors.New("unexpected signing method") |
38 | 44 | ) |
39 | 45 | |
46 | // Claims is a map of arbitrary claim data. | |
40 | 47 | type Claims map[string]interface{} |
41 | 48 | |
42 | 49 | // NewSigner creates a new JWT token generating middleware, specifying key ID, |