token

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Key   = "auth.token.%s"
	IDKey = "auth.id.%d"
)

Variables

This section is empty.

Functions

func GetTokenIdKey added in v1.0.0

func GetTokenIdKey(id int64) string

func GetTokenKey added in v1.0.0

func GetTokenKey(session string) string

func Tokens added in v1.0.0

func Tokens() kid.Middleware

Types

type Option

type Option func(*Options)

func WithExpire

func WithExpire(expire int) Option

func WithSecret

func WithSecret(secret string) Option

type Options

type Options struct {
	// contains filtered or unexported fields
}

type RedisStore added in v1.0.0

type RedisStore struct {
	// contains filtered or unexported fields
}

func (*RedisStore) Expired added in v1.0.0

func (rs *RedisStore) Expired(license string) error

func (*RedisStore) Get added in v1.0.0

func (rs *RedisStore) Get(token string) (*tokenInfo, error)

func (*RedisStore) Provide added in v1.0.0

func (rs *RedisStore) Provide() interface{}

func (*RedisStore) Save added in v1.0.0

func (rs *RedisStore) Save(token string, session *tokenInfo) error

type Store added in v1.0.0

type Store interface {
	Get(license string) (*tokenInfo, error)
	Save(license string, user *tokenInfo) error
	Expired(license string) error
}

type Token

type Token struct {
	Store Store `inject:""`
	// contains filtered or unexported fields
}

func Default

func Default() *Token

func New

func New(opts ...Option) *Token

func (*Token) Cancellation

func (guard *Token) Cancellation(license string) error

func (*Token) ExpiresAt

func (guard *Token) ExpiresAt(license string) int64

func (*Token) IssuerAt

func (guard *Token) IssuerAt(license string) int64

func (*Token) License

func (guard *Token) License(user *guard.User) (string, error)

func (*Token) Provide

func (guard *Token) Provide() interface{}

func (*Token) Verify

func (guard *Token) Verify(license string) (*guard.User, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL