emtoken

package module
v0.0.0-...-c46fb09 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

README

emix-token

go get github.com/go-emix/emix-token

Support cluster deployment (redis)

Documentation

Index

Constants

View Source
const SaltSource string = "adcdefghjkmnpqrstuvwxyz1234567890ABCDEFGHJKLMNPQRSTUVWXYZ9876543210"

Variables

View Source
var SignKey = ""
View Source
var TokenExpiredErr = errors.New("token expired")
View Source
var TokenInvalidErr = errors.New("token invalid")
View Source
var TokenMalformedErr = errors.New("token malformed error")
View Source
var TokenNotAvailableErr = errors.New("token not available")
View Source
var TokenNotValidYetErr = errors.New("token not valid yet")

Functions

func Available

func Available(token string) bool

func Destroy

func Destroy(token string, expired time.Duration) error

func GenDefaultToken

func GenDefaultToken(claim DefaultClaims) (string, error)

func NewRedisClient

func NewRedisClient(c RedisConfig) *redis.Client

func RandGenSalt

func RandGenSalt() string

func SetStore

func SetStore(store Store)

Types

type DefaultClaims

type DefaultClaims struct {
	jwt.StandardClaims
	Id       int
	Nickname string
	Phone    string
	Name     string
	Salt     string
}

func ParseDefaultToken

func ParseDefaultToken(token string) (*DefaultClaims, error)

type EmixConfig

type EmixConfig struct {
	Token TokenConfig `yaml:"token"`
}

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) Available

func (r *MemoryStore) Available(token string) bool

func (*MemoryStore) Destroy

func (r *MemoryStore) Destroy(token string, expired time.Duration) error

type Operation

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

func AfterInit

func AfterInit(yamlFile string, rc ...RedisConfig) (oper Operation)

func (Operation) Setup

func (r Operation) Setup()

type RedisConfig

type RedisConfig struct {
	Addr     string `yaml:"addr"`
	Password string `yaml:"password"`
	Username string `yaml:"username"`
}

type RedisStore

type RedisStore struct {
	*redis.Client
	// contains filtered or unexported fields
}

func NewRedisStore

func NewRedisStore(config RedisConfig) *RedisStore

func (*RedisStore) Available

func (r *RedisStore) Available(token string) bool

func (*RedisStore) Destroy

func (r *RedisStore) Destroy(token string, expired time.Duration) error

type RootConfig

type RootConfig struct {
	Emix EmixConfig `yaml:"emix"`
}

type Store

type Store interface {
	Destroy(token string, expired time.Duration) error
	Available(token string) bool
}

type TokenConfig

type TokenConfig struct {
	Redis   RedisConfig `yaml:"redis"`
	SignKey string      `yaml:"signKey"`
}

Jump to

Keyboard shortcuts

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