Documentation ¶
Index ¶
- Variables
- type Storage
- func (receiver *Storage) Clone() osin.Storage
- func (receiver *Storage) Close()
- func (receiver *Storage) CreateClient(client osin.Client) error
- func (receiver *Storage) CreateSchema() error
- func (receiver *Storage) DropSchema() error
- func (receiver *Storage) GetClient(id string) (osin.Client, error)
- func (receiver *Storage) LoadAccess(token string) (accessData *osin.AccessData, err error)
- func (receiver *Storage) LoadAuthorize(code string) (authorizeData *osin.AuthorizeData, err error)
- func (receiver *Storage) LoadRefresh(token string) (accessData *osin.AccessData, err error)
- func (receiver *Storage) RemoveAccess(token string) error
- func (receiver *Storage) RemoveAuthorize(code string) error
- func (receiver *Storage) RemoveClient(id string) error
- func (receiver *Storage) RemoveRefresh(token string) error
- func (receiver *Storage) SaveAccess(accessData *osin.AccessData) error
- func (receiver *Storage) SaveAuthorize(authorizeData *osin.AuthorizeData) error
- func (receiver *Storage) SaveRefresh(accessData *osin.AccessData) error
- type StorageConfig
- type UserData
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClientNotFound is returned by GetClient if client was not found ErrClientNotFound = osin.ErrNotFound // ErrAuthorizeNotFound is returned by LoadAuthorize if authorization code was not found ErrAuthorizeNotFound = osin.ErrNotFound // ErrAccessNotFound is returned by LoadAccess if access token was not found ErrAccessNotFound = osin.ErrNotFound // ErrRefreshNotFound is returned by LoadRefresh if refresh token was not found ErrRefreshNotFound = osin.ErrNotFound // ErrTokenExpired is returned by LoadAccess, LoadAuthorize or LoadRefresh if token or code expired ErrTokenExpired = errors.New("Token expired") )
Functions ¶
This section is empty.
Types ¶
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage implements the storage interface for OSIN (https://github.com/RangelReale/osin) with Amazon DynamoDB (https://aws.amazon.com/dynamodb/) using aws-sdk-go (https://github.com/aws/aws-sdk-go).
func New ¶
func New(db *dynamodb.DynamoDB, config StorageConfig) *Storage
New returns a new DynamoDB storage instance.
func (*Storage) Clone ¶
Clone the storage if needed. Has no effect with this library, it's only to satisfy interface.
func (*Storage) Close ¶
func (receiver *Storage) Close()
Close the resources the Storage potentially holds. Has no effect with this library, it's only to satisfy interface.
func (*Storage) CreateClient ¶
CreateClient adds new client. This is not a part of interface and as so, it's never used in osin flow. However can be really usefull for applications to add new clients.
func (*Storage) CreateSchema ¶
CreateSchema initiates db with basic schema layout This is not a part of interface but can be useful for initiating basic schema and for tests
func (*Storage) DropSchema ¶
DropSchema drops all tables This is not a part of interface but can be useful in tests
func (*Storage) LoadAccess ¶
func (receiver *Storage) LoadAccess(token string) (accessData *osin.AccessData, err error)
LoadAccess retrieves access data by token. Client information is loaded together. Can return error if expired.
func (*Storage) LoadAuthorize ¶
func (receiver *Storage) LoadAuthorize(code string) (authorizeData *osin.AuthorizeData, err error)
LoadAuthorize looks up AuthorizeData by a code. Client information is loaded together. Can return error if expired.
func (*Storage) LoadRefresh ¶
func (receiver *Storage) LoadRefresh(token string) (accessData *osin.AccessData, err error)
LoadRefresh retrieves refresh AccessData. Client information is loaded together. Refresh token doesn't expire.
func (*Storage) RemoveAccess ¶
RemoveAccess revokes or deletes an AccessData.
func (*Storage) RemoveAuthorize ¶
RemoveAuthorize revokes or deletes the authorization code.
func (*Storage) RemoveClient ¶
RemoveClient revokes or deletes client. This is not a part of interface and as so, it's never used in osin flow. However can be really usefull for applications to remove or revoke clients.
func (*Storage) RemoveRefresh ¶
RemoveRefresh revokes or deletes refresh AccessData.
func (*Storage) SaveAccess ¶
func (receiver *Storage) SaveAccess(accessData *osin.AccessData) error
SaveAccess writes AccessData.
func (*Storage) SaveAuthorize ¶
func (receiver *Storage) SaveAuthorize(authorizeData *osin.AuthorizeData) error
SaveAuthorize saves authorize data.
func (*Storage) SaveRefresh ¶
func (receiver *Storage) SaveRefresh(accessData *osin.AccessData) error
SaveRefresh writes AccessData for refresh token This method is not a part of interface and as so, it's never used in osin flow. This method is used internally by SaveAccess(accessData *osin.AccessData) and can be useful for testing
type StorageConfig ¶
type StorageConfig struct { // ClientTable is the name of table for clients ClientTable string // AuthorizeTable is the name of table for authorization codes AuthorizeTable string // AccessTable is the name of table for access tokens AccessTable string // RefreshTable is the name of table for refresh tokens RefreshTable string // CreateUserData is a function that allows you to create struct // to which osin.AccessData.UserData will be json.Unmarshaled. // Example: // struct AppUserData{ // Username string // } // func() interface{} { // return &AppUserData{} // } CreateUserData func() interface{} }
StorageConfig allows to pass configuration to Storage on initialization
func CreateStorageConfig ¶
func CreateStorageConfig(prefix string) StorageConfig
CreateStorageConfig prefixes all table names and returns StorageConfig
type UserData ¶
type UserData interface { // ToAttributeValues lists user data as attribute values for DynamoDB table ToAttributeValues() map[string]*dynamodb.AttributeValue }
UserData is an interface that allows you to store UserData values as DynamoDB attributes in AccessTable and RefreshTable