mysqltokenstore

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Oauth2Type

func Oauth2Type(db *gorm.DB) *gorm.DB

Types

type TokenStore

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

func NewTokenStore

func NewTokenStore(options ...TokenStoreOption) (*TokenStore, error)

NewTokenStore creates PostgreSQL store instance

func (*TokenStore) Close

func (s *TokenStore) Close() error

Close close the store

func (*TokenStore) Create

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

Create create and store the new token information

func (*TokenStore) GetByAccess

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

GetByAccess use the access token for token information data

func (*TokenStore) GetByCode

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

GetByCode use the authorization code for token information data

func (*TokenStore) GetByRefresh

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

GetByRefresh use the refresh token for token information data

func (*TokenStore) RemoveByAccess

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

RemoveByAccess use the access token to delete the token information

func (*TokenStore) RemoveByCode

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

RemoveByCode delete the authorization code

func (*TokenStore) RemoveByRefresh

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

RemoveByRefresh use the refresh token to delete the token information

type TokenStoreItem

type TokenStoreItem struct {
	ID            string `gorm:"primary_key"`
	Scope         string
	ScopeId       string
	AccessKey     string
	SecretKey     string
	Status        string
	Description   string
	CreatorID     string
	Type          string
	CreatedAt     time.Time
	UpdatedAt     time.Time
	ExpiredAt     *time.Time
	Code          string
	Data          TokenStoreItemData
	Refresh       string
	SoftDeletedAt uint64
}

TokenStoreItem data item

func (*TokenStoreItem) BeforeCreate

func (t *TokenStoreItem) BeforeCreate(scope *gorm.Scope) (err error)

func (TokenStoreItem) TableName

func (TokenStoreItem) TableName() string

func (*TokenStoreItem) ToPbToken

func (t *TokenStoreItem) ToPbToken() *pb.Token

type TokenStoreItemData

type TokenStoreItemData struct {
	TokenInfo oauth2.TokenInfo `json:"tokenInfo"`
}

func (*TokenStoreItemData) Scan

func (data *TokenStoreItemData) Scan(value interface{}) error

func (TokenStoreItemData) Value

func (data TokenStoreItemData) Value() (driver.Value, error)

type TokenStoreOption

type TokenStoreOption func(s *TokenStore)

TokenStoreOption is the configuration options type for token store

func WithTokenStoreGCDisabled

func WithTokenStoreGCDisabled() TokenStoreOption

WithTokenStoreGCDisabled returns option that disables token store garbage collection

func WithTokenStoreGCInterval

func WithTokenStoreGCInterval(gcInterval time.Duration) TokenStoreOption

WithTokenStoreGCInterval returns option that sets token store garbage collection interval

type TokenType

type TokenType string
const (
	OAuth2    TokenType = "OAuth2"
	AccessKey TokenType = "AccessKey"
	PAT       TokenType = "PAT"
)

func (TokenType) String

func (s TokenType) String() string

Jump to

Keyboard shortcuts

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