Versions in this module Expand all Collapse all v1 v1.0.0 Aug 23, 2023 Changes in this version + const ValidationErrorAudience + const ValidationErrorClaimsInvalid + const ValidationErrorExpired + const ValidationErrorId + const ValidationErrorIssuedAt + const ValidationErrorIssuer + const ValidationErrorMalformed + const ValidationErrorNotValidYet + const ValidationErrorSignatureInvalid + const ValidationErrorUnverifiable + var ErrECDSAVerification = errors.New("crypto/ecdsa: verification error") + var ErrHashUnavailable = errors.New("the requested hash function is unavailable") + var ErrInvalidKey = errors.New("key is invalid") + var ErrInvalidKeyType = errors.New("key is of invalid type") + var TimeFunc = time.Now + func DecodeSegment(seg string) ([]byte, error) + func EncodeSegment(seg []byte) string + func RegisterSigningMethod(alg string, f func() SigningMethod) + type Claims interface + Valid func() error + type Keyfunc func(*Token) (any, error) + type MapClaims map[string]any + func (m MapClaims) Valid() error + func (m MapClaims) VerifyAudience(cmp string, req bool) bool + func (m MapClaims) VerifyExpiresAt(cmp int64, req bool) bool + func (m MapClaims) VerifyIssuedAt(cmp int64, req bool) bool + func (m MapClaims) VerifyIssuer(cmp string, req bool) bool + func (m MapClaims) VerifyNotBefore(cmp int64, req bool) bool + type Parser struct + SkipClaimsValidation bool + UseJSONNumber bool + ValidMethods []string + func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) + func (p *Parser) ParseUnverified(tokenString string, claims Claims) (token *Token, parts []string, err error) + func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc) (*Token, error) + type SigningMethod interface + Alg func() string + Sign func(signingString string, key any) (string, error) + Verify func(signingString, signature string, key any) error + func GetSigningMethod(alg string) (method SigningMethod) + type SigningMethodECDSA struct + CurveBits int + Hash crypto.Hash + KeySize int + Name string + var SigningMethodES256 *SigningMethodECDSA + var SigningMethodES384 *SigningMethodECDSA + var SigningMethodES512 *SigningMethodECDSA + func (m *SigningMethodECDSA) Alg() string + func (m *SigningMethodECDSA) Sign(signingString string, key any) (string, error) + func (m *SigningMethodECDSA) Verify(signingString, signature string, key any) error + type SigningMethodHMAC struct + Hash crypto.Hash + Name string + var ErrSignatureInvalid = errors.New("signature is invalid") + var SigningMethodHS256 *SigningMethodHMAC + var SigningMethodHS384 *SigningMethodHMAC + var SigningMethodHS512 *SigningMethodHMAC + func (m *SigningMethodHMAC) Alg() string + func (m *SigningMethodHMAC) Sign(signingString string, key any) (string, error) + func (m *SigningMethodHMAC) Verify(signingString, signature string, key any) error + type SigningMethodRSA struct + Hash crypto.Hash + Name string + var SigningMethodRS256 *SigningMethodRSA + var SigningMethodRS384 *SigningMethodRSA + var SigningMethodRS512 *SigningMethodRSA + func (m *SigningMethodRSA) Alg() string + func (m *SigningMethodRSA) Sign(signingString string, key any) (string, error) + func (m *SigningMethodRSA) Verify(signingString, signature string, key any) error + type SigningMethodRSAPSS struct + Options *rsa.PSSOptions + VerifyOptions *rsa.PSSOptions + var SigningMethodPS256 *SigningMethodRSAPSS + var SigningMethodPS384 *SigningMethodRSAPSS + var SigningMethodPS512 *SigningMethodRSAPSS + func (m *SigningMethodRSAPSS) Sign(signingString string, key any) (string, error) + func (m *SigningMethodRSAPSS) Verify(signingString, signature string, key any) error + type StandardClaims struct + Audience string + ExpiresAt int64 + Id string + IssuedAt int64 + Issuer string + NotBefore int64 + Subject string + func (c *StandardClaims) VerifyAudience(cmp string, req bool) bool + func (c *StandardClaims) VerifyExpiresAt(cmp int64, req bool) bool + func (c *StandardClaims) VerifyIssuedAt(cmp int64, req bool) bool + func (c *StandardClaims) VerifyIssuer(cmp string, req bool) bool + func (c *StandardClaims) VerifyNotBefore(cmp int64, req bool) bool + func (c StandardClaims) Valid() error + type Token struct + Claims Claims + Header map[string]any + Method SigningMethod + Raw string + Signature string + Valid bool + func New(method SigningMethod) *Token + func NewWithClaims(method SigningMethod, claims Claims) *Token + func Parse(tokenString string, keyFunc Keyfunc) (*Token, error) + func ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc) (*Token, error) + func (t *Token) SignedString(key any) (string, error) + func (t *Token) SigningString() (string, error) + type ValidationError struct + Errors uint32 + Inner error + func NewValidationError(errorText string, errorFlags uint32) *ValidationError + func (e ValidationError) Error() string