Versions in this module Expand all Collapse all v0 v0.0.2 Feb 14, 2019 Changes in this version + var ErrInvalidSignature = errors.New("invalid signature") + var ErrPartMissed = errors.New("one of token parts missed") + var ErrRequestedHashUnavailable = errors.New("requested hash function is unavailable") + type Algorithm string + const ES256 + const ES384 + const ES512 + const HS256 + const HS384 + const HS512 + const PS256 + const PS384 + const RS256 + const RS384 + const RS512 + type Builder interface + Build func(claims encoding.BinaryMarshaler, signer Signer, key Key) (*DecodedParts, error) + type ClaimsValidator struct + func NewClaimsValidator() *ClaimsValidator + func (v *ClaimsValidator) Validate(claims RegisteredClaims, constraints ...Constraint) (errs []error) + type Constraint interface + Validate func(claims RegisteredClaims) error + type DecodedParts struct + func (t *DecodedParts) Header() Header + func (t *DecodedParts) MarshalBinary() (data []byte, err error) + func (t *DecodedParts) MarshalText() (text []byte, err error) + func (t *DecodedParts) Payload() []byte + func (t *DecodedParts) RawClaims() []byte + func (t *DecodedParts) Signature() []byte + type Header struct + Alg Algorithm + Cty string + Jku string + Kid string + Typ string + X5t string + X5u string + type JSONParser struct + func NewJSONParser() *JSONParser + func (p *JSONParser) Parse(jwt json.RawMessage) (*DecodedParts, error) + type Key struct + func NewSharedSecretKey(secret []byte) Key + func (k Key) Secret() []byte + type Parser interface + Parse func(jwt json.RawMessage) (*DecodedParts, error) + type PartsVerifier struct + func NewPartsVerifier(signer Signer, key Key) *PartsVerifier + func (v *PartsVerifier) Verify(parts *DecodedParts) error + type RegisteredClaims struct + Aud []string + Exp Timestamp + Iat Timestamp + Iss string + Jti string + Nbf Timestamp + Sub string + func (c RegisteredClaims) HasBeenCrossedNotBefore(now time.Time) bool + func (c RegisteredClaims) HasBeenIssuedBefore(now time.Time) bool + func (c RegisteredClaims) HasBeenIssuedBy(issuers ...string) bool + func (c RegisteredClaims) IsExpired(now time.Time) bool + func (c RegisteredClaims) IsIdentifiedBy(id string) bool + func (c RegisteredClaims) IsPermittedFor(audience string) bool + func (c RegisteredClaims) IsRelatedTo(subject string) bool + type Signer interface + GetAlgorithmID func() Algorithm + Sign func(payload []byte, key Key) ([]byte, error) + Verify func(expected, payload []byte, key Key) error + type Timestamp int64 + func (t *Timestamp) UnmarshalJSON(data []byte) error + func (t Timestamp) Time() time.Time + type TokenBuilder struct + func NewTokenBuilder() *TokenBuilder + func (b *TokenBuilder) Build(claims encoding.BinaryMarshaler, signer Signer, key Key) (*DecodedParts, error) + func (b *TokenBuilder) WithKID(kid string) *TokenBuilder + type Validator interface + Validate func(claims RegisteredClaims, constraints ...Constraint) []error + type VerifyingParser struct + func NewVerifyingParser(parser Parser, verifier *PartsVerifier) *VerifyingParser + func (p *VerifyingParser) Parse(jwt json.RawMessage) (*DecodedParts, error)