manage

package
Version: v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2016 License: Apache-2.0 Imports: 8 Imported by: 62

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilValue Nil Value
	ErrNilValue = errors.New("nil value")

	// ErrClientNotFound Client not Found
	ErrClientNotFound = errors.New("client not found")

	// ErrClientInvalid Client invalid
	ErrClientInvalid = errors.New("client invalid")

	// ErrAuthCodeInvalid Authorize token invalid
	ErrAuthCodeInvalid = errors.New("authorize code invalid")

	// ErrAccessInvalid Access token expired
	ErrAccessInvalid = errors.New("access token invalid")

	// ErrAccessExpired Access token expired
	ErrAccessExpired = errors.New("access token expired")

	// ErrRefreshInvalid Refresh token invalid
	ErrRefreshInvalid = errors.New("refresh token invalid")

	// ErrRefreshExpired Refresh token expired
	ErrRefreshExpired = errors.New("refresh token expired")
)

Functions

func ValidateURI

func ValidateURI(domain string, redirectURI string) error

ValidateURI 校验重定向的URI与域名的一致性

Types

type Config

type Config struct {
	TokenExp   time.Duration // 令牌有效期
	RefreshExp time.Duration // 更新令牌有效期
}

Config 授权配置参数

type Manager

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

Manager OAuth2授权管理

func NewManager

func NewManager() *Manager

NewManager 创建Manager的实例

func NewMongoManager

func NewMongoManager(mongoCfg *token.MongoConfig) *Manager

NewMongoManager 创建基于mongodb存储的管理实例

func NewRedisManager

func NewRedisManager(redisCfg *token.RedisConfig) *Manager

NewRedisManager 创建基于redis存储的管理实例

func (*Manager) GenerateAccessToken

func (m *Manager) GenerateAccessToken(gt oauth2.GrantType, tgr *oauth2.TokenGenerateRequest) (accessToken oauth2.TokenInfo, err error)

GenerateAccessToken 生成访问令牌、更新令牌 gt 授权模式 tgr 生成令牌的参数

func (*Manager) GenerateAuthToken

func (m *Manager) GenerateAuthToken(rt oauth2.ResponseType, tgr *oauth2.TokenGenerateRequest) (authToken oauth2.TokenInfo, err error)

GenerateAuthToken 生成授权令牌 rt 授权类型 tgr 生成令牌的配置参数

func (*Manager) GetClient

func (m *Manager) GetClient(clientID string) (cli oauth2.ClientInfo, err error)

GetClient 获取客户端信息 clientID 客户端标识

func (*Manager) LoadAccessToken

func (m *Manager) LoadAccessToken(access string) (info oauth2.TokenInfo, err error)

LoadAccessToken 加载访问令牌信息

func (*Manager) LoadRefreshToken

func (m *Manager) LoadRefreshToken(refresh string) (info oauth2.TokenInfo, err error)

LoadRefreshToken 加载更新令牌信息

func (*Manager) MapAccessGenerate

func (m *Manager) MapAccessGenerate(gen oauth2.AccessGenerate)

MapAccessGenerate 注入访问令牌生成接口

func (*Manager) MapAuthorizeGenerate

func (m *Manager) MapAuthorizeGenerate(gen oauth2.AuthorizeGenerate)

MapAuthorizeGenerate 注入授权令牌生成接口

func (*Manager) MapClientModel

func (m *Manager) MapClientModel(cli oauth2.ClientInfo)

MapClientModel 注入客户端信息模型

func (*Manager) MapClientStorage

func (m *Manager) MapClientStorage(stor oauth2.ClientStore)

MapClientStorage 注入客户端信息存储接口

func (*Manager) MapTokenModel

func (m *Manager) MapTokenModel(token oauth2.TokenInfo)

MapTokenModel 注入令牌信息模型

func (*Manager) MapTokenStorage

func (m *Manager) MapTokenStorage(stor oauth2.TokenStore)

MapTokenStorage 注入令牌信息存储接口

func (*Manager) MustClientStorage

func (m *Manager) MustClientStorage(stor oauth2.ClientStore, err error)

MustClientStorage 强制注入客户端信息存储接口

func (*Manager) MustTokenStorage

func (m *Manager) MustTokenStorage(stor oauth2.TokenStore, err error)

MustTokenStorage 强制注入令牌信息存储接口

func (*Manager) RefreshAccessToken

func (m *Manager) RefreshAccessToken(tgr *oauth2.TokenGenerateRequest) (accessToken oauth2.TokenInfo, err error)

RefreshAccessToken 更新访问令牌

func (*Manager) RemoveAccessToken

func (m *Manager) RemoveAccessToken(access string) (err error)

RemoveAccessToken 删除访问令牌

func (*Manager) RemoveRefreshToken

func (m *Manager) RemoveRefreshToken(refresh string) (err error)

RemoveRefreshToken 删除更新令牌

func (*Manager) SetGTConfig

func (m *Manager) SetGTConfig(gt oauth2.GrantType, cfg *Config)

SetGTConfig 设定授权模式配置参数 gt 授权模式 cfg 配置参数

func (*Manager) SetRTConfig

func (m *Manager) SetRTConfig(rt oauth2.ResponseType, cfg *Config)

SetRTConfig 设定授权类型配置参数 rt 授权类型 cfg 配置参数

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL