oauthtoken

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheAlert

type CacheAlert struct {
	LoadStorer
	// contains filtered or unexported fields
}

CacheAlert is a tokenLoadStorer that detects when a token's subject for a different cluster is changing, and produces a warning over an appropriate communication channel.

func (*CacheAlert) Store

func (a *CacheAlert) Store(cluster string, token *oauth2.Token) error

type DebugPrint

type DebugPrint struct{}

func (*DebugPrint) Load

func (d *DebugPrint) Load(ctx context.Context, cluster string) (*oauth2.Token, error)

func (*DebugPrint) Store

func (d *DebugPrint) Store(ctx context.Context, cluster string, token *oauth2.Token) error

type FakeTokenStore added in v0.0.3

type FakeTokenStore struct {
	Tokens                       map[string]*oauth2.Token
	LoadErr, StoreErr, DeleteErr error
}

FakeTokenStore is a test implementation of LoadStorer that stores tokens in memory instead of the system keychain.

func NewFakeTokenStore added in v0.0.3

func NewFakeTokenStore() *FakeTokenStore

func (*FakeTokenStore) Delete added in v0.0.3

func (f *FakeTokenStore) Delete(cluster string) error

func (*FakeTokenStore) Load added in v0.0.3

func (f *FakeTokenStore) Load(cluster string) (*oauth2.Token, error)

func (*FakeTokenStore) Store added in v0.0.3

func (f *FakeTokenStore) Store(cluster string, token *oauth2.Token) error

func (*FakeTokenStore) WithDeleteErr added in v0.0.5

func (f *FakeTokenStore) WithDeleteErr(err error) *FakeTokenStore

func (*FakeTokenStore) WithLoadErr added in v0.0.5

func (f *FakeTokenStore) WithLoadErr(err error) *FakeTokenStore

func (*FakeTokenStore) WithStoreErr added in v0.0.5

func (f *FakeTokenStore) WithStoreErr(err error) *FakeTokenStore

func (*FakeTokenStore) WithToken added in v0.0.5

func (f *FakeTokenStore) WithToken(cluster string, token *oauth2.Token) *FakeTokenStore

type Fallback added in v0.0.5

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

Fallback composes multiple backends into a single backend that:

  • delegates Store() operations to a single specific backend
  • delegates Load() operations to each backend of a list in turn, returning the token from the first backend to succeed
  • delegates Delete() operations to all backends

func (*Fallback) Delete added in v0.0.5

func (f *Fallback) Delete(cluster string) error

Delete attempts to delete credentials for the named cluster from every `backend` (but not `storeBackend` explicitly, which should also be present in the list of all backends).

If any delete succeeded, then the entire operation is successful. Otherwise, if all errors are "not found", an error that compares to `fs.ErrNotFound` is returned. Otherwise, one of the errors could be a backend where the token was found but not successfully deleted; these errors are propagated as-is.

func (*Fallback) Load added in v0.0.5

func (f *Fallback) Load(cluster string) (*oauth2.Token, error)

Load tries to load a token from each of `backends`, returning the first successful response, or all the resulting errors.

func (*Fallback) Store added in v0.0.5

func (f *Fallback) Store(cluster string, token *oauth2.Token) error

type FileStore added in v0.0.5

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

FileStore persists tokens in JSON files in a directory, one file per token. The tokens are stored unecrypted. This implementation may be used when Keyring cannot be used, for example, in a CI environment when there is no encrypted keyring.

func NewFileTokenStore added in v0.0.5

func NewFileTokenStore(dir string) (*FileStore, error)

func (*FileStore) Delete added in v0.0.5

func (f *FileStore) Delete(cluster string) error

func (*FileStore) Load added in v0.0.5

func (f *FileStore) Load(cluster string) (_ *oauth2.Token, err error)

func (*FileStore) Store added in v0.0.5

func (f *FileStore) Store(cluster string, token *oauth2.Token) (err error)

type Keyring

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

Keyring stores a JWT token on the user's keyring via the OS-specific keyring mechanism of the current platform.

func (*Keyring) Delete added in v0.0.3

func (f *Keyring) Delete(cluster string) error

func (*Keyring) Load

func (f *Keyring) Load(cluster string) (*oauth2.Token, error)

func (*Keyring) Store

func (f *Keyring) Store(cluster string, token *oauth2.Token) error

type LoadStorer

type LoadStorer interface {
	// Load loads a token for a cluster, specified by hostname. It returns
	// fs.ErrNotFound if the token isn't present, or an unspecified non-nil
	// error for any other error conditions.
	Load(cluster string) (*oauth2.Token, error)

	// Store stores a token for a cluster, specified by hostname. It returns an
	// unspecified non-nil error if the operation fails; in this case, the state
	// of the token storage for the specified cluster is not specified (token
	// storage for other clusters is unaffected).
	Store(cluster string, token *oauth2.Token) error

	// Delete deletes a token for a cluster, specified by hostname. It returns
	// fs.ErrNotFound if there is currently no token stored for the specified
	// cluster, or an unspecified non-nil error for any other error conditions
	// (although the storage backend should make a best-effort attempt to delete
	// the token).
	Delete(string) error
}

LoadStorer provides access to a token via some backend implementation/policy.

func NewCacheAlert

func NewCacheAlert(impl LoadStorer, stderr io.Writer) LoadStorer

func NewFallback added in v0.0.5

func NewFallback(storeBackend LoadStorer, backends ...LoadStorer) LoadStorer

NewFallback returns a backend that delegates Store() operations to `storeBackend` and Load()/Delete() operations to `backends` (see docs for Fallback). `storeBackend` should be repeated as an element of `backends` if it should be used for Load()/Delete() operations (which is the common case), though it does not need to be the first element.

func NewKeyring

func NewKeyring() (LoadStorer, error)

Jump to

Keyboard shortcuts

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