store

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	C_ACCESS_TOKEN  = "access_token"
	C_REFRESH_TOKEN = "refresh_token"
)

Variables

This section is empty.

Functions

func NewMemoryTokenStoreInstance

func NewMemoryTokenStoreInstance() *memoryTokenStore

NewMemoryTokenStoreInstance 实例化

Types

type ClientInfo

type ClientInfo struct {
	ClientId             string
	ClientSecret         string
	GrantType            []common.GrantType
	Scope                []string
	AccessTokenDuration  time.Duration
	RefreshTokenDuration time.Duration
}

ClientInfo 客户端信息

type ClientStore

type ClientStore interface {
	// GetClient 获取客户端
	GetClient(clientId string) (*ClientInfo, error)
	// AddClient 追加客户端信息
	AddClient(clientInfo *ClientInfo) error
	// RemoveClient 删除客户端信息
	RemoveClient(clientId string) error
}

ClientStore 接口

func NewMemoryClientStoreInstance

func NewMemoryClientStoreInstance() ClientStore

获取内存类型 Client Store

func NewMySQLClientStoreInstance

func NewMySQLClientStoreInstance() ClientStore

获取 Client Store

type TokenStore

type TokenStore interface {
	// 生成token
	GenerateToken(
		clientInfo *ClientInfo,
		userName string,
		scope []string,
		roles []string,
		authorities []string,
		customPayload map[string]interface{}) (accessToken, refreshToken string, err error)

	// 刷新token
	RefreshToken(
		refreshToken string,
		clientInfo *ClientInfo,
		userName string,
		scope []string,
		roles []string,
		authorities []string,
		customPayload map[string]interface{}) (accessTokenRtn, refreshTokenRtn string, err error)

	// 检查AccessToken
	CheckAccessToken(accessToken string) bool
}

TokenStore TokenStore接口

目前实现: 内存类型:store.memoryClientStore MySQL类型: store.mySQLClientStore

Jump to

Keyboard shortcuts

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