Documentation ¶
Overview ¶
Package datastore is osin storage plugin for Google Cloud Datastore
Index ¶
- Constants
- Variables
- type Client
- type ClientStorage
- func (cl *ClientStorage) Delete(ctx context.Context, id string) error
- func (cl *ClientStorage) DeleteMulti(ctx context.Context, ids []string) error
- func (cl *ClientStorage) Get(ctx context.Context, id string) (*Client, error)
- func (cl *ClientStorage) GetMulti(ctx context.Context, ids []string) ([]*Client, error)
- func (cl *ClientStorage) Put(ctx context.Context, c *Client) error
- func (cl *ClientStorage) PutMulti(ctx context.Context, cs []*Client) error
- type Storage
- func (d *Storage) Clone() osin.Storage
- func (d *Storage) Close()
- func (d *Storage) GetClient(id string) (osin.Client, error)
- func (d *Storage) LoadAccess(token string) (*osin.AccessData, error)
- func (d *Storage) LoadAuthorize(code string) (*osin.AuthorizeData, error)
- func (d *Storage) LoadRefresh(token string) (*osin.AccessData, error)
- func (d *Storage) RemoveAccess(token string) error
- func (d *Storage) RemoveAuthorize(code string) error
- func (d *Storage) RemoveRefresh(token string) error
- func (d *Storage) SaveAccess(a *osin.AccessData) error
- func (d *Storage) SaveAuthorize(auth *osin.AuthorizeData) error
Constants ¶
const KindAccessData = "access_data"
KindAccessData is datastore kind name of OAuth2 access token
const KindAuthorizeData = "authorize_data"
KindAuthorizeData is datastore kind name of OAuth2 authorize data stored
const KindClient = "client"
KindClient is datastore kind name of OAuth2 client stored
const KindRefresh = "refresh"
KindRefresh is datastore kind name of OAuth2 refresh token
Variables ¶
var ( ErrEmptyClientID = errors.New("ID field of Client is empty") ErrInvalidUserDataType = errors.New("UserData field must be string") )
Error definitions
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { ID string `json:"id,omitempty" datastore:"-"` Secret string `json:"secret,omitempty" datastore:",noindex"` RedirectUri string `json:"redirect_uri,omitempty" datastore:",noindex"` UserData string `json:"user_data,omitempty" datastore:",noindex"` }
Client is struct of OAuth2 client.
func (*Client) GetRedirectUri ¶
GetRedirectUri return redirect uri
func (*Client) GetUserData ¶
func (c *Client) GetUserData() interface{}
GetUserData return user data of client
type ClientStorage ¶
type ClientStorage struct {
// contains filtered or unexported fields
}
ClientStorage is datastore handler for client.
func NewClientStorage ¶
func NewClientStorage(ctx context.Context, opt ...datastore.ClientOption) (*ClientStorage, error)
NewClientStorage create ClientStorage object. The object created by this constructor uses Google Cloud Client Library for Go. If you want to use on Google App Engine Standard Edition, it should be recommanded to create object by NewClientStorageForGAE rather than use this.
func NewClientStorageForGAE ¶
func NewClientStorageForGAE(ctx context.Context, opt ...datastore.ClientOption) (*ClientStorage, error)
NewClientStorageForGAE create ClientStorage object. The object created by this constructor uses Google App Engine SDK for Go. If you want to use on other of Google App Engine Standard Edition, you must create object by NewClientStorage rather than use this.
func (*ClientStorage) Delete ¶
func (cl *ClientStorage) Delete(ctx context.Context, id string) error
Delete removes client entitye for id from Datastore.
func (*ClientStorage) DeleteMulti ¶
func (cl *ClientStorage) DeleteMulti(ctx context.Context, ids []string) error
DeleteMulti removes multiple clients entitye for ids from Datastore.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage is handler to store OAuth2 tokens at GCP Datastore.
This struct must be live in only request scope. So, instance should be created at like each "handler.ServeHTTP" methods.
func NewStorage ¶
NewStorage is constructor for storage of Google Cloud Datastore. The object created by this constructor uses Google Cloud Client Library for Go. If you want to use on Google App Engine Standard Edition, it should be recommanded to create object by NewStorageForGAE rather than use this.
func NewStorageForGAE ¶
NewStorageForGAE is constructor for storage of Google Cloud Datastore. The object created by this constructor uses Google App Engine SDK for Go. If you want to use on other of Google App Engine Standard Edition, you must create object by NewStorage rather than use this.
func (*Storage) Close ¶
func (d *Storage) Close()
Close releases resources used as datastore connections. This method must be call to finish use storage instance.
func (*Storage) GetClient ¶
GetClient loads client entity from datastore. If there is no match entity for the id, GetClient returns osin.ErrNotFound.
func (*Storage) LoadAccess ¶
func (d *Storage) LoadAccess(token string) (*osin.AccessData, error)
LoadAccess loads accesstoken data entity for access token with authorize data entity and client entity from datastore. If there is no match entity for the access token, LoadAuthorize returns osin.ErrNotFound.
func (*Storage) LoadAuthorize ¶
func (d *Storage) LoadAuthorize(code string) (*osin.AuthorizeData, error)
LoadAuthorize loads authorize data entity with client entity from datastore. If there is no match entity for the id, LoadAuthorize returns osin.ErrNotFound.
func (*Storage) LoadRefresh ¶
func (d *Storage) LoadRefresh(token string) (*osin.AccessData, error)
LoadRefresh loads accesstoken data entity for refresh token with authorize data entity and client entity from datastore. If there is no match entity for the refresh token, LoadAuthorize returns osin.ErrNotFound.
func (*Storage) RemoveAccess ¶
RemoveAccess delete accesstoken data from datastore.
func (*Storage) RemoveAuthorize ¶
RemoveAuthorize delete authorize data from datastore.
func (*Storage) RemoveRefresh ¶
RemoveRefresh delete refreshtoken data from datastore.
func (*Storage) SaveAccess ¶
func (d *Storage) SaveAccess(a *osin.AccessData) error
SaveAccess stores accesstoken entity to datastore.
func (*Storage) SaveAuthorize ¶
func (d *Storage) SaveAuthorize(auth *osin.AuthorizeData) error
SaveAuthorize stores authorize data entity to datastore.