tokenstore

package
v1.71.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("auth token not found")
)

Functions

func WithKeyring

func WithKeyring(k keyring.Keyring) func(o *Opts)

WithKeyring specifies a custom keyring to use.

Types

type InMemoryTokenStore

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

func NewInMemoryTokenStore

func NewInMemoryTokenStore() *InMemoryTokenStore

func (*InMemoryTokenStore) Clear

func (ts *InMemoryTokenStore) Clear() error

func (*InMemoryTokenStore) Save

func (ts *InMemoryTokenStore) Save(token *oauth2.Token) error

func (*InMemoryTokenStore) Token

func (ts *InMemoryTokenStore) Token() (*oauth2.Token, error)

type Keyring added in v1.22.0

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

Keyring is a wrapper around 99designs/keyring that handles config via env vars and marshalling/unmarshalling of items.

func (*Keyring) Clear added in v1.22.0

func (s *Keyring) Clear(key string) error

func (*Keyring) HasKey added in v1.22.0

func (s *Keyring) HasKey(key string) (bool, error)

returns false if the key is not found, true if it is found, or false and an error if there was a keyring related error

func (*Keyring) List added in v1.22.0

func (s *Keyring) List() ([]keyring.Item, error)

func (*Keyring) ListKeys added in v1.22.0

func (s *Keyring) ListKeys() ([]string, error)

func (*Keyring) Retrieve added in v1.22.0

func (s *Keyring) Retrieve(key string, target interface{}) error

returns keyring.ErrKeyNotFound if not found

func (*Keyring) Store added in v1.22.0

func (s *Keyring) Store(key string, payload interface{}) error

type NotifyRefreshTokenSource

type NotifyRefreshTokenSource struct {
	New oauth2.TokenSource

	T         *oauth2.Token
	SaveToken TokenNotifyFunc // called when token refreshed so new refresh token can be persisted
	// contains filtered or unexported fields
}

NotifyRefreshTokenSource is essentially `oauth2.ResuseTokenSource` with `TokenNotifyFunc` added.

func (*NotifyRefreshTokenSource) Token

func (s *NotifyRefreshTokenSource) Token() (*oauth2.Token, error)

Token returns the current token if it's still valid, else will refresh the current token (using r.Context for HTTP client information) and return the new one.

type Opts

type Opts struct {
	Name string

	// Keyring is a custom keyring to use rather than
	// the default one, which is configured with
	// environment variables.
	Keyring keyring.Keyring
}

type Storage

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

func New

func New(opts Opts) Storage

New creates a new token storage driver. The context is the authentication context to use. This is usually 'default' and in future can be expanded to allow CLI users to switch between separate Common Fate tenancies.

func (*Storage) Clear

func (s *Storage) Clear() error

Clear the token

func (*Storage) Save

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

Save the token

func (*Storage) Token

func (s *Storage) Token() (*oauth2.Token, error)

Token returns the token.

type TokenNotifyFunc

type TokenNotifyFunc func(*oauth2.Token) error

TokenNotifyFunc is a function that accepts an oauth2 Token upon refresh, and returns an error if it should not be used.

type WindowsOpts added in v1.33.1

type WindowsOpts struct {
	Name string

	// Keyring is a custom keyring to use rather than
	// the default one, which is configured with
	// environment variables.
	Keyring keyring.Keyring
}

type WindowsStorage added in v1.33.1

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

func NewWindows added in v1.33.1

func NewWindows(opts Opts) WindowsStorage

New creates a new token storage driver. The context is the authentication context to use. This is usually 'default' and in future can be expanded to allow CLI users to switch between separate Common Fate tenancies.

func (*WindowsStorage) Clear added in v1.33.1

func (s *WindowsStorage) Clear() error

Clear the token

func (*WindowsStorage) Save added in v1.33.1

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

Save the token

func (*WindowsStorage) Token added in v1.33.1

func (s *WindowsStorage) Token() (*oauth2.Token, error)

Token returns the token.

Jump to

Keyboard shortcuts

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