auth

package
v0.0.0-...-7c98ed9 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package auth is a generated GoMock package.

Index

Constants

View Source
const (
	EnvProduction  Env = "production"
	EnvDevelopment     = "development"
	EnvSandbox         = "sandbox"
)

Variables

This section is empty.

Functions

func EndpointFromEnv

func EndpointFromEnv(target *oauth2.Endpoint, env Env) error

Types

type Authorization

type Authorization struct {
	Config *oauth2.Config
	// contains filtered or unexported fields
}

Authorization provides features that help the authorization process and managing tokens, such as getting tokens from the data sources and persisting refreshed tokens. Most users will use golang.org/x/oauth2 package.

func NewAuthorization

func NewAuthorization(cnf *oauth2.Config, ts TokenStore) *Authorization

func (*Authorization) AuthCodeURL

func (a *Authorization) AuthCodeURL(state string) string

func (*Authorization) AuthorizeCLI

func (a *Authorization) AuthorizeCLI(state string) error

func (*Authorization) AuthorizeFromCode

func (a *Authorization) AuthorizeFromCode(ctx context.Context, code string) error

func (*Authorization) Client

func (a *Authorization) Client(ctx context.Context) (*http.Client, error)

type Env

type Env string

type FileTokenStore

type FileTokenStore struct {
	Path string
}

FileTokenStore is a data source managing tokens.

func NewFileTokenStore

func NewFileTokenStore(path string) *FileTokenStore

func (*FileTokenStore) Get

func (s *FileTokenStore) Get() (*oauth2.Token, error)

func (*FileTokenStore) Save

func (s *FileTokenStore) Save(token *oauth2.Token) error

type MockTokenStore

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

MockTokenStore is a mock of TokenStore interface.

func NewMockTokenStore

func NewMockTokenStore(ctrl *gomock.Controller) *MockTokenStore

NewMockTokenStore creates a new mock instance.

func (*MockTokenStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTokenStore) Get

func (m *MockTokenStore) Get() (*oauth2.Token, error)

Get mocks base method.

func (*MockTokenStore) Save

func (m *MockTokenStore) Save(arg0 *oauth2.Token) error

Save mocks base method.

type MockTokenStoreMockRecorder

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

MockTokenStoreMockRecorder is the mock recorder for MockTokenStore.

func (*MockTokenStoreMockRecorder) Get

Get indicates an expected call of Get.

func (*MockTokenStoreMockRecorder) Save

func (mr *MockTokenStoreMockRecorder) Save(arg0 interface{}) *gomock.Call

Save indicates an expected call of Save.

type TokenStore

type TokenStore interface {
	// Get returns the persisted token from some data source.
	Get() (*oauth2.Token, error)

	// Store persists the token into some data source.
	Save(*oauth2.Token) error
}

TokenStore is anything that can get token and store token, with any datasource. (e.g. cache, database)

Jump to

Keyboard shortcuts

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