tokenstores

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = &DefaultStore{}
View Source
var ErrTokenInvalid = errors.New("token is invalid")
View Source
var ErrTokenNotFound = errors.New("token not found")

Functions

func NewFileTokenStore

func NewFileTokenStore(path string, logger *zap.Logger) *fileTokenStore

func NewMongoClient

func NewMongoClient(user, password, host, port string, usessl bool, logger *zap.Logger) *mongo.Client

Types

type DefaultStore

type DefaultStore struct {
}

func (*DefaultStore) ContainsScopes

func (ts *DefaultStore) ContainsScopes(token *oauth2.Token, scopes ...string) bool

func (*DefaultStore) GetDecoded

func (ts *DefaultStore) GetDecoded(token *oauth2.Token) *TokenItem

func (*DefaultStore) GetID

func (ts *DefaultStore) GetID(token *oauth2.Token) int32

func (*DefaultStore) GetJTI

func (ts *DefaultStore) GetJTI(token *oauth2.Token) string

func (*DefaultStore) GetName

func (ts *DefaultStore) GetName(token *oauth2.Token) string

func (*DefaultStore) GetScopes

func (ts *DefaultStore) GetScopes(token *oauth2.Token) []string

func (*DefaultStore) MatchScopes

func (ts *DefaultStore) MatchScopes(token *oauth2.Token, scopes ...string) bool

type TokenItem

type TokenItem struct {
	ID            primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"`
	AccessToken   string             `bson:"AccessToken" json:"token"`
	RefreshToken  string             `bson:"RefreshToken" json:"refresh_token"`
	TokenType     string             `bson:"TokenType" json:"token_type"`
	CharacterName string             `bson:"CharacterName" json:"character_name"`
	CharacterID   int32              `bson:"characterID" json:"character_id"`
	Expiry        time.Time          `bson:"Expiry" json:"expiry"`
	OwnerHash     string             `bson:"OwnerHash" json:"owner"`
	JTI           string             `bson:"JTI" json:"jti"`
	Scopes        []string           `bson:"scopes" json:"scopes"`
}

type TokenStore

type TokenStore interface {
	Create(token *oauth2.Token) error
	Read(CharacterID string, Scopes ...string) (*oauth2.Token, error)
	Update(oldtoken *oauth2.Token, newtoken *oauth2.Token) error
	Delete(token *oauth2.Token) error
}

func NewBadgerTokenStore

func NewBadgerTokenStore(logger *zap.Logger, db *badgerhold.Store) TokenStore

func NewMongoTokenStore

func NewMongoTokenStore(db *mongo.Client, database string, collection string, logger *zap.Logger) TokenStore

Jump to

Keyboard shortcuts

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