token

package
v1.3.50 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: Zlib Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KSource  = "source"
	KSession = "session"
	KExtend  = "extend"
	KUid     = "uid"
)

Variables

This section is empty.

Functions

func IsBase64Enabled added in v1.3.18

func IsBase64Enabled(opts ...Option) bool

Types

type Authenticate added in v0.5.9

type Authenticate interface {
	Type() string
	Create(source Source, expireSeconds int64, opts ...Option) (Token, error)
	Decode(source Source, tk string, opts ...Option) (Token, error)
	Check(source Source, tk string, opts ...Option) (Token, error)
	// EnableFlag return 0= disable, 1=enable, 2=not exist
	EnableFlag(source Source) int
	SetEnabled(source Source, enable bool)
}

type Engine added in v0.5.11

type Engine interface {
	Client() Route
	Server() Route
}

type Factory added in v1.3.18

type Factory interface {
	Create(key Key, opts ...Option) (Token, error)
	Decode(tk string, opts ...Option) (Token, error)
	Check(tk string, key Key, opts ...Option) (Token, error)
}

type Key

type Key secret.Key

type Option added in v1.2.20

type Option struct {
	Base64 bool //是否使用base64编码
}

type Route added in v0.5.11

type Route interface {
	HasAuth(method string) bool
	Auth() Authenticate
	Use(a Authenticate) Route
}

type Secret added in v0.5.11

type Secret interface {
	GetSecret(source Source) secret.Secret
	SetEnabled(source Source, enable bool)
	// EnableFlag return 0= disable, 1=enable, 2=not exist
	EnableFlag(source Source) int
}

type Session

type Session struct {
	Uid       string `json:"uid"`
	UserToken string `json:"-"` //for server and server
}

func CreateSession added in v1.2.20

func CreateSession(uid, session string) Session

type Source added in v0.5.9

type Source struct {
	AppId     string      `json:"appid"`
	Source    string      `json:"source"`
	SecretKey string      `json:"-"`
	Method    string      `json:"-"` //认证方式 "jwt
	Custom    interface{} `json:"-"` //自定义数据
}

type Token

type Token interface {
	// WithVar key= "source" value= token.Source
	//         key= "session" value= token.Session
	//         key= "extend" value= string
	WithVar(key string, value interface{}) Token
	GetVar(key string) interface{}
	GetToken() string
	Update() (string, error)
}

Jump to

Keyboard shortcuts

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