datastore

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package datastore is osin storage plugin for Google Cloud Datastore

Index

Constants

View Source
const KindAccessData = "access_data"

KindAccessData is datastore kind name of OAuth2 access token

View Source
const KindAuthorizeData = "authorize_data"

KindAuthorizeData is datastore kind name of OAuth2 authorize data stored

View Source
const KindClient = "client"

KindClient is datastore kind name of OAuth2 client stored

View Source
const KindRefresh = "refresh"

KindRefresh is datastore kind name of OAuth2 refresh token

Variables

View Source
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) GetId

func (c *Client) GetId() string

GetId return client id.

func (*Client) GetRedirectUri

func (c *Client) GetRedirectUri() string

GetRedirectUri return redirect uri

func (*Client) GetSecret

func (c *Client) GetSecret() string

GetSecret return client secret.

func (*Client) GetUserData

func (c *Client) GetUserData() interface{}

GetUserData return user data of client

func (Client) String

func (c Client) String() string

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.

func (*ClientStorage) Get

func (cl *ClientStorage) Get(ctx context.Context, id string) (*Client, error)

Get search client for given id.

func (*ClientStorage) GetMulti

func (cl *ClientStorage) GetMulti(ctx context.Context, ids []string) ([]*Client, error)

GetMulti search multiple client for given ids.

func (*ClientStorage) Put

func (cl *ClientStorage) Put(ctx context.Context, c *Client) error

Put create or update client entity. The ID field of Client uses as Datastore's key.

func (*ClientStorage) PutMulti

func (cl *ClientStorage) PutMulti(ctx context.Context, cs []*Client) error

PutMulti create or update multiple client entities. The ID field of Client uses as Datastore's key.

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

func NewStorage(ctx context.Context, opts ...datastore.ClientOption) (*Storage, error)

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

func NewStorageForGAE(ctx context.Context, opts ...datastore.ClientOption) (*Storage, error)

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) Clone

func (d *Storage) Clone() osin.Storage

Clone is clonning storage instance

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

func (d *Storage) GetClient(id string) (osin.Client, error)

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

func (d *Storage) RemoveAccess(token string) error

RemoveAccess delete accesstoken data from datastore.

func (*Storage) RemoveAuthorize

func (d *Storage) RemoveAuthorize(code string) error

RemoveAuthorize delete authorize data from datastore.

func (*Storage) RemoveRefresh

func (d *Storage) RemoveRefresh(token string) error

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.

Jump to

Keyboard shortcuts

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