tokenstore

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 10 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 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.

Jump to

Keyboard shortcuts

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