oauth2xorm

package module
v0.0.0-...-c70775d Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: MIT Imports: 11 Imported by: 0

README

go-oauth2-xorm

Credits

Based on https://github.com/go-oauth2/mysql/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

Config xorm configuration

func NewConfig

func NewConfig(dsn string, dbType string, tableName string) *Config

NewConfig create mysql configuration instance

type Store

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

Store mysql token store

func NewStore

func NewStore(config *Config, gcInterval int) *Store

NewStore create mysql store instance,

func NewStoreWithDB

func NewStoreWithDB(config *Config, x *xorm.Engine, gcInterval int) *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 {
	ID        int64 `xorm:"pk autoincr"`
	ExpiredAt int64
	Code      string `xorm:"varchar(512)"`
	Access    string `xorm:"varchar(512)"`
	Refresh   string `xorm:"varchar(512)"`
	Data      string `xorm:"text"`
}

StoreItem data item

Jump to

Keyboard shortcuts

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