auth

package
v2.0.77 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken     = errors.New("invalid token")
	ErrInvalidSignature = errors.New("signature is invalid")
)

定义错误

Functions

This section is empty.

Types

type Auther

type Auther interface {
	// 生成令牌
	GenerateToken(ctx context.Context, mapClaims MapClaims) (TokenInfo, error)

	// 销毁令牌
	DestroyToken(ctx context.Context, accessToken string) error

	// 解析用户
	ParseUser(ctx context.Context, accessToken string) (*MapClaims, error)

	// 释放资源
	Release() error
}

Auther 认证接口

type MapClaims

type MapClaims map[string]interface{}

func (*MapClaims) DecodeJSON

func (m *MapClaims) DecodeJSON(body []byte) error

func (*MapClaims) EncodeToJSON

func (m *MapClaims) EncodeToJSON() ([]byte, error)

type TokenInfo

type TokenInfo interface {
	// 获取访问令牌
	GetAccessToken() string
	// 获取令牌类型
	GetTokenType() string
	// 获取令牌到期时间戳
	GetExpiresAt() int64
	// JSON编码
	EncodeToJSON() ([]byte, error)
}

TokenInfo 令牌信息

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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