token

package
Version: v2.1.0+incompatible 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: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMongoStore

func NewMongoStore(cfg *MongoConfig) (store oauth2.TokenStore, err error)

NewMongoStore 创建MongoDB的令牌存储

func NewRedisStore

func NewRedisStore(cfg *RedisConfig) (store oauth2.TokenStore, err error)

NewRedisStore 创建redis存储的实例

Types

type MongoConfig

type MongoConfig struct {
	// Connection String
	URL string
	// DB Name(default oauth2)
	DB string
	// Collection Name(default tokens)
	C string
}

MongoConfig MongoDB Configuration

type MongoStore

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

MongoStore MongoDB Store

func (*MongoStore) Create

func (ms *MongoStore) Create(info oauth2.TokenInfo) (err error)

Create 存储令牌信息

func (*MongoStore) GetByAccess

func (ms *MongoStore) GetByAccess(access string) (info oauth2.TokenInfo, err error)

GetByAccess 获取令牌数据

func (*MongoStore) GetByRefresh

func (ms *MongoStore) GetByRefresh(refresh string) (info oauth2.TokenInfo, err error)

GetByRefresh 获取令牌数据

func (*MongoStore) RemoveByAccess

func (ms *MongoStore) RemoveByAccess(access string) (err error)

RemoveByAccess 移除令牌

func (*MongoStore) RemoveByRefresh

func (ms *MongoStore) RemoveByRefresh(refresh string) (err error)

RemoveByRefresh 移除令牌

type RedisConfig

type RedisConfig struct {
	// The network type, either tcp or unix.
	// Default is tcp.
	Network string
	// host:port address.
	Addr string

	// An optional password. Must match the password specified in the
	// requirepass server configuration option.
	Password string
	// A database to be selected after connecting to server.
	DB int

	// The maximum number of retries before giving up.
	// Default is to not retry failed commands.
	MaxRetries int

	// Sets the deadline for establishing new connections. If reached,
	// dial will fail with a timeout.
	// Default is 5 seconds.
	DialTimeout time.Duration
	// Sets the deadline for socket reads. If reached, commands will
	// fail with a timeout instead of blocking.
	ReadTimeout time.Duration
	// Sets the deadline for socket writes. If reached, commands will
	// fail with a timeout instead of blocking.
	WriteTimeout time.Duration

	// The maximum number of socket connections.
	// Default is 10 connections.
	PoolSize int
	// Specifies amount of time client waits for connection if all
	// connections are busy before returning an error.
	// Default is 1 second.
	PoolTimeout time.Duration
}

RedisConfig Redis Configuration

type RedisStore

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

RedisStore 令牌的redis存储

func (*RedisStore) Create

func (rs *RedisStore) Create(info oauth2.TokenInfo) (err error)

Create 存储令牌信息

func (*RedisStore) GetByAccess

func (rs *RedisStore) GetByAccess(access string) (ti oauth2.TokenInfo, err error)

GetByAccess 获取令牌数据

func (*RedisStore) GetByRefresh

func (rs *RedisStore) GetByRefresh(refresh string) (ti oauth2.TokenInfo, err error)

GetByRefresh 获取令牌数据

func (*RedisStore) RemoveByAccess

func (rs *RedisStore) RemoveByAccess(access string) (err error)

RemoveByAccess 移除令牌

func (*RedisStore) RemoveByRefresh

func (rs *RedisStore) RemoveByRefresh(refresh string) (err error)

RemoveByRefresh 移除令牌

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