tokenstore

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is the expected error if the token is not found in the keyring
	ErrNotFound = errors.New("failed retrieving token from keyring")

	// ErrInvalidToken is the expected error if the token is not a valid one
	ErrInvalidToken = errors.New("invalid token")
)

Functions

This section is empty.

Types

type KeyringRepository

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

KeyringRepository represents a repository provided by different secrets backend using `99designs/keyring` package.

func NewKeyringRepository

func NewKeyringRepository(backend string, promptFunc *keyring.PromptFunc, keyringDir string) (*KeyringRepository, error)

NewKeyringRepository creates a new repository backend could be used to select which backed will be used. If it's empty the library will select the most suitable depending OS.

All currently supported secure storage backends:

SecretServiceBackend BackendType = "secret-service"
KeychainBackend      BackendType = "keychain"
KWalletBackend       BackendType = "kwallet"
WinCredBackend       BackendType = "wincred"
FileBackend          BackendType = "file"
PassBackend          BackendType = "pass"

func (*KeyringRepository) Close

func (r *KeyringRepository) Close() error

Close closes the keyring repository.

func (*KeyringRepository) Get added in v1.2.0

func (r *KeyringRepository) Get(email string) (*oauth2.Token, error)

getToken returns the specified token from the repository.

func (*KeyringRepository) Set added in v1.2.0

func (r *KeyringRepository) Set(email string, token *oauth2.Token) error

Set stores a token into the OS keyring.

type Repository added in v1.2.0

type Repository interface {
	Get(key string) (*oauth2.Token, error)
	Set(key string, token *oauth2.Token) error
	Close() error
}

Repository is responsible to store tokens somewhere.

type TokenManager

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

TokenManager allows to store and retrieve Token from a repository.

func New added in v1.2.0

func New(repo Repository) *TokenManager

New returns a TokenManager using the specified repo.

func (*TokenManager) Close

func (tm *TokenManager) Close() error

Close closes the Token repository.

func (*TokenManager) RetrieveToken

func (tm *TokenManager) RetrieveToken(email string) (*oauth2.Token, error)

RetrieveToken returns the Token from the repository.

func (*TokenManager) StoreToken

func (tm *TokenManager) StoreToken(email string, token *oauth2.Token) error

StoreToken stores the Token into the repository.

Jump to

Keyboard shortcuts

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