store

package
Version: v0.0.0-...-6cf4ca1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStoreWithDB

func NewStoreWithDB(config *TokenConfig, db *gorm.DB, gcInterval int) (store oauth2.TokenStore, err error)

NewStoreWithDB create store with config

func NewTokenStore

func NewTokenStore(config *TokenConfig, gcInterval int) (store oauth2.TokenStore, err error)

NewTokenStore create mysql store instance,

Types

type ClientConfig

type ClientConfig struct {
	DSN       string
	DBType    string
	TableName string
}

ClientConfig xorm configuration

func NewClientConfig

func NewClientConfig(dsn string, dbType string, tableName string) *ClientConfig

NewClientConfig create mysql configuration instance

type ClientItem

type ClientItem struct {
	//ID        int64 `gorm:"AUTO_INCREMENT"`
	ID        string `gorm:"type:varchar(512)"`
	Secret    string `gorm:"type:varchar(512)"`
	Domain    string `gorm:"type:varchar(512)"`
	UserID    string `gorm:"type:varchar(512)"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

ClientItem data item

type ClientStore

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

ClientStore client information store

func NewClientStore

func NewClientStore(config *ClientConfig) (client *ClientStore, err error)

NewClientStore create a token store instance based on memory

func NewClientWithDB

func NewClientWithDB(config *ClientConfig, db *gorm.DB) (client *ClientStore, err error)

NewClientWithDB create client store

func (*ClientStore) GetByID

func (cs *ClientStore) GetByID(id string) (cli oauth2.ClientInfo, err error)

GetByID according to the ID for the client information

func (*ClientStore) Set

func (cs *ClientStore) Set(id string, cli oauth2.ClientInfo) (err error)

Set set client information

type Store

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

Store mysql token store

func (*Store) Close

func (s *Store) Close()

Close close the store

func (*Store) Create

func (s *Store) Create(info oauth2.TokenInfo) error

Create create and store the new token information

func (*Store) GetByAccess

func (s *Store) GetByAccess(access string) (oauth2.TokenInfo, error)

GetByAccess use the access token for token information data

func (*Store) GetByCode

func (s *Store) GetByCode(code string) (oauth2.TokenInfo, error)

GetByCode use the authorization code for token information data

func (*Store) GetByRefresh

func (s *Store) GetByRefresh(refresh string) (oauth2.TokenInfo, error)

GetByRefresh use the refresh token for token information data

func (*Store) RemoveByAccess

func (s *Store) RemoveByAccess(access string) error

RemoveByAccess use the access token to delete the token information

func (*Store) RemoveByCode

func (s *Store) RemoveByCode(code string) error

RemoveByCode delete the authorization code

func (*Store) RemoveByRefresh

func (s *Store) RemoveByRefresh(refresh string) error

RemoveByRefresh use the refresh token to delete the token information

func (*Store) SetStdout

func (s *Store) SetStdout(stdout io.Writer) *Store

SetStdout set error output

type StoreItem

type StoreItem struct {
	gorm.Model
	//ID        int64 `gorm:"AUTO_INCREMENT"`
	ExpiredAt int64
	Code      string `gorm:"type:varchar(512)"`
	Access    string `gorm:"type:varchar(512)"`
	Refresh   string `gorm:"type:varchar(512)"`
	Data      string `gorm:"type:text"`
}

StoreItem data item saved into db

type TokenConfig

type TokenConfig struct {
	DSN         string
	DBType      string
	TableName   string
	MaxLifetime time.Duration
}

TokenConfig xorm configuration

func NewTokenConfig

func NewTokenConfig(dsn string, dbType string, tableName string) *TokenConfig

NewTokenConfig create mysql configuration instance

Source Files

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