Documentation ¶
Index ¶
- Variables
- type Claims
- func (self *Claims) Contains(key string) bool
- func (self Claims) Get(key string) (interface{}, error)
- func (self *Claims) GetString(key string) (string, error)
- func (self *Claims) GetTime(key string) (time.Time, error)
- func (self *Claims) Set(key string, value interface{})
- func (self *Claims) SetTime(key string, value time.Time)
- type Header
- type JWT
- func (token *JWT) Decode(encoded string) (*Claims, error)
- func (token *JWT) DecodeAndValidate(encoded string) (claims *Claims, err error)
- func (token *JWT) Encode(payload *Claims) (string, error)
- func (token *JWT) NewHeader() *Header
- func (token *JWT) Sign(unsignedToken string) ([]byte, error)
- func (token *JWT) Validate(encoded string) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Claims errors. ErrClaimDoesNotExist = errors.New("claim does not exist") ErrClaimNotAString = errors.New("claim is not a string") ErrClaimNotAnInt64 = errors.New("claim is not an int64") // Token's errors. ErrTokenIsMalformed = errors.New("malformed token") ErrTokenHasExpired = errors.New("token has expired") ErrTokenInvalidSignature = errors.New("invalid signature") ErrTokenUnableToSign = errors.New("unable to sign token") ErrTokenNotValid = errors.New("token isn't valid yet") ErrTokenUnableToMarshallHeader = errors.New("unable to marshal header") ErrTokenUnableToMarshallPayload = errors.New("unable to marshal payload") ErrTokenUnableToDecodeB64Payload = errors.New("unable to decode base64 payload") ErrTokenUnableToUnmarshallPayload = errors.New("unable to unmarshal payload json") )
Functions ¶
This section is empty.
Types ¶
type Claims ¶
type Claims struct {
// contains filtered or unexported fields
}
func NewClaims ¶
func NewClaims() *Claims
NewClaims returns a new map representing the claims with "iat" claim value.
func (Claims) Get ¶
Get returns the claim in string form and returns an error if the specified claim doesn't exist.
type Header ¶
type Header struct { // Token type. Typ string // Message authentication code algorithm - the issuer can freely set an algorithm // to verify the signature on the token. However, some asymmetrical algorithms // pose security concerns. Alg string // Content type - this always is JWT. Cty string }
Represents JWT Header. Contains important information for encrypting/decrypting.
type JWT ¶
type JWT struct {
// contains filtered or unexported fields
}
JWT is used to sign and validate a token.
func HmacSha256 ¶
HmacSha256 returns the SingingMethod for HMAC with SHA256
func HmacSha384 ¶
HmacSha384 returns the SigningMethod for HMAC with SHA384
func HmacSha512 ¶
HmacSha512 returns the SigningMethod for HMAC with SHA512
func (*JWT) Decode ¶
Decode returns a map representing the token's claims. DOESN'T validate the claims though.
func (*JWT) DecodeAndValidate ¶
DecodeAndValidate returns a map representing the token's claims, and it's valid.
Click to show internal directories.
Click to hide internal directories.