Documentation
¶
Index ¶
- Constants
- Variables
- type ClientStore
- type ClientStoreItem
- type ClientStoreOption
- type TokenStore
- func (s *TokenStore) Create(ctx context.Context, info oauth2.TokenInfo) error
- func (s *TokenStore) GetByAccess(ctx context.Context, access string) (oauth2.TokenInfo, error)
- func (s *TokenStore) GetByCode(ctx context.Context, code string) (oauth2.TokenInfo, error)
- func (s *TokenStore) GetByRefresh(ctx context.Context, refresh string) (oauth2.TokenInfo, error)
- func (s *TokenStore) RemoveByAccess(ctx context.Context, access string) error
- func (s *TokenStore) RemoveByCode(ctx context.Context, code string) error
- func (s *TokenStore) RemoveByRefresh(ctx context.Context, refresh string) error
- type TokenStoreItem
- type TokenStoreOption
Constants ¶
const (
// DefaultClientStoreCollection is the default collection for storing clients.
DefaultClientStoreCollection = "oauth2_clients"
)
const ( // DefaultTokenStoreCollection is the default collection for storing tokens. DefaultTokenStoreCollection = "oauth2_tokens" // nolint: gosec )
Variables ¶
var ( // ErrNoCollection is returned when no collection is provided. ErrNoCollection = fmt.Errorf("no collection provided") // ErrNoDatabase is returned when no database is provided. ErrNoDatabase = fmt.Errorf("no database provided") )
Functions ¶
This section is empty.
Types ¶
type ClientStore ¶
type ClientStore struct {
// contains filtered or unexported fields
}
ClientStore is a data struct that stores oauth2 client information.
func NewClientStore ¶
func NewClientStore(opts ...ClientStoreOption) (*ClientStore, error)
NewClientStore creates a new ClientStore.
func (*ClientStore) Create ¶
func (s *ClientStore) Create(info oauth2.ClientInfo) error
Create creates a new client in the store.
type ClientStoreItem ¶
type ClientStoreItem struct { Key string `json:"_key"` Secret string `json:"secret"` Domain string `json:"domain"` Data []byte `json:"data"` }
ClientStoreItem data item
type ClientStoreOption ¶
type ClientStoreOption func(*ClientStore) error
ClientStoreOption is a function that configures the ClientStore.
func WithClientStoreCollection ¶
func WithClientStoreCollection(collection string) ClientStoreOption
WithClientStoreCollection configures the collection for the ClientStore.
func WithClientStoreDatabase ¶
func WithClientStoreDatabase(db arangoDriver.Database) ClientStoreOption
WithClientStoreDatabase configures the database for the ClientStore.
type TokenStore ¶
type TokenStore struct {
// contains filtered or unexported fields
}
TokenStore is a data struct that stores oauth2 client information.
func NewTokenStore ¶
func NewTokenStore(opts ...TokenStoreOption) (*TokenStore, error)
NewTokenStore creates a new TokenStore.
func (*TokenStore) Create ¶
func (s *TokenStore) Create(ctx context.Context, info oauth2.TokenInfo) error
Create creates a new token in the store.
func (*TokenStore) GetByAccess ¶
func (s *TokenStore) GetByAccess(ctx context.Context, access string) (oauth2.TokenInfo, error)
GetByAccess returns the token by its access token.
func (*TokenStore) GetByCode ¶
func (s *TokenStore) GetByCode(ctx context.Context, code string) (oauth2.TokenInfo, error)
GetByCode returns the token by its authorization code.
func (*TokenStore) GetByRefresh ¶
func (s *TokenStore) GetByRefresh(ctx context.Context, refresh string) (oauth2.TokenInfo, error)
GetByRefresh returns the token by its refresh token.
func (*TokenStore) RemoveByAccess ¶
func (s *TokenStore) RemoveByAccess(ctx context.Context, access string) error
func (*TokenStore) RemoveByCode ¶
func (s *TokenStore) RemoveByCode(ctx context.Context, code string) error
RemoveByCode deletes the token by its authorization code.
func (*TokenStore) RemoveByRefresh ¶
func (s *TokenStore) RemoveByRefresh(ctx context.Context, refresh string) error
type TokenStoreItem ¶
type TokenStoreItem struct { Key string `json:"_key,omitempty"` Code string `json:"code"` Access string `json:"access_token"` Refresh string `json:"refresh_token"` Data []byte `json:"data"` CreatedAt time.Time `json:"created_at"` ExpiresAt time.Time `json:"expires_at"` }
TokenStoreItem data item
type TokenStoreOption ¶
type TokenStoreOption func(*TokenStore) error
TokenStoreOption is a function that configures the TokenStore.
func WithTokenStoreCollection ¶
func WithTokenStoreCollection(collection string) TokenStoreOption
WithTokenStoreCollection configures the collection for the TokenStore.
func WithTokenStoreDatabase ¶
func WithTokenStoreDatabase(db arangoDriver.Database) TokenStoreOption
WithTokenStoreDatabase configures the database for the TokenStore.