db_token

package
v0.0.0-...-94183c9 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenTableName = "op_auth_user_token"
)

Functions

This section is empty.

Types

type AuthUserToken

type AuthUserToken struct {
	ID        uint   `gorm:"primary_key;AUTO_INCREMENT"`
	Uid       string `gorm:"size:32;index:ind_uid_provider"`
	Provider  string `gorm:"size:32;index:ind_uid_provider"`
	Token     string `gorm:"size:32;index:idx_token"`
	TokenInfo string `gorm:"type:TEXT"`
	IP        string `gorm:"size:32"`
	ExpiredAt int64
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (AuthUserToken) TableName

func (AuthUserToken) TableName() string

type Config

type Config struct {
	DB             *gorm.DB
	ExpireDuration time.Duration
	PrivateKeyPath string
	PublicKeyPath  string
	JwtSignMethod  string
}

type Module

type Module struct {
	*Config
	// contains filtered or unexported fields
}

func New

func New(cfg *Config) (*Module, error)

func (*Module) ClearToken

func (m *Module) ClearToken(tokenMd5 string) error

清除Token

func (*Module) ClearTokenOfUser

func (m *Module) ClearTokenOfUser(uid string, provider string) error

清除用户的Token

func (*Module) EncodeToken

func (m *Module) EncodeToken(jwtToken string) string

func (*Module) ExistUser

func (m *Module) ExistUser(id string, provider string) bool

func (*Module) FindToken

func (m *Module) FindToken(tokenMd5 string) (user map[string]string)

查找token

func (*Module) NewToken

func (m *Module) NewToken(user map[string]string) (string, int64, error)

新Token

func (*Module) StoreToken

func (m *Module) StoreToken(claim *UserClaims, jwtToken string) (string, error)

type UserClaims

type UserClaims struct {
	*jwt.StandardClaims
	User map[string]string
}

Jump to

Keyboard shortcuts

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