Versions in this module Expand all Collapse all v1 v1.1.2 Nov 14, 2023 v1.1.1 Nov 14, 2023 Changes in this version + var TokenInvalidError = errors.New("invalid token") + func CompareHashAndPassword(hashedPassword, password string) error + func CreateToken(sourceID any, data map[string]interface{}) (string, error) + func DestroyAllToken(sourceID any) error + func DestroyToken(sourceID any, uid string) error + func GenerateHashedPassword(password string) (string, error) + func InitDefaultVerifier(jwtKey string, tokenStorage TokenStorage, options ...Option) + func RefreshToken(sourceID any, uid string, data map[string]interface{}) (string, error) + type CustomClaims struct + Data map[string]interface{} + SourceID any + UUID string + func IsTokenAuthorized(tokenStr string) (CustomClaims, bool) + func VerifyToken(tokenStr string) (CustomClaims, string, error) + func (c *CustomClaims) IsParamsValid() bool + type Option interface + Apply func(*Verifier) + func WithAuthExpireDuration(duration time.Duration) Option + func WithJwtTimeFunc(timeFunc func() time.Time) Option + func WithSourceName(sourceName string) Option + func WithTempTokenExpireDuration(duration time.Duration) Option + func WithTokenExpireDuration(duration time.Duration) Option + type OptionFunc func(*Verifier) + func (f OptionFunc) Apply(verifier *Verifier) + type TokenStorage interface + Del func(key string) error + DelByKeyPrefix func(keyPrefix string) error + Exists func(key string) bool + Get func(key string) (string, error) + Set func(key string, value interface{}, expiration time.Duration) error + SetNX func(key string, value interface{}, expiration time.Duration) bool + type Verifier struct + func DefaultVerifierVerifier() *Verifier + func New(jwtKey string, tokenStorage TokenStorage, options ...Option) *Verifier + func (v *Verifier) CreateToken(sourceID any, data map[string]interface{}) (string, error) + func (v *Verifier) DestroyAllToken(sourceID any) error + func (v *Verifier) DestroyToken(sourceID any, uid string) error + func (v *Verifier) IsTokenAuthorized(tokenStr string) (CustomClaims, bool) + func (v *Verifier) RefreshToken(sourceID any, uid string, data map[string]interface{}) (string, error) + func (v *Verifier) VerifyToken(tokenStr string) (CustomClaims, string, error)