tokenstore

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tokenstore persists the OIDC refresh token between runs so a new certificate can be requested without an interactive login.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyPath = errors.New("token store path was empty")

ErrEmptyPath is returned by NewFileStore when no path is given

Functions

This section is empty.

Types

type DiscardStore

type DiscardStore struct{}

DiscardStore is a Store that does not persist the token, so a login is needed on each run

func NewDiscardStore

func NewDiscardStore() (*DiscardStore, error)

NewDiscardStore creates a new DiscardStore however, new(DiscardStore) (or just declaring a DiscardStore variable) is sufficient to initialize a DiscardStore.

func (*DiscardStore) Delete

func (s *DiscardStore) Delete() error

Delete does nothing and always succeeds

func (*DiscardStore) Get

func (s *DiscardStore) Get() string

Get always returns an empty string

func (*DiscardStore) Set

func (s *DiscardStore) Set(v string) error

Set discards v and always succeeds

type FileStore added in v0.24.0

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

FileStore is a Store that keeps the token in a plain file, for systems without a keyring such as servers. The token is not encrypted, so it is only protected by the permissions on the file, which is created readable and writable only by its owner. On Windows those permissions are not applied, so the file is protected only by the access control list it inherits.

func NewFileStore added in v0.24.0

func NewFileStore(path string) (*FileStore, error)

NewFileStore creates a FileStore that keeps the token in the file at path. The file does not need to exist until FileStore.Set is called.

func (*FileStore) Delete added in v0.24.0

func (s *FileStore) Delete() error

Delete removes the token file. Nothing is done if the file does not exist.

func (*FileStore) Get added in v0.24.0

func (s *FileStore) Get() string

Get returns the token from the file, or an empty string if the file does not exist or could not be read. Surrounding whitespace, such as a trailing newline added when the file was edited by hand, is removed.

func (*FileStore) Set added in v0.24.0

func (s *FileStore) Set(v string) error

Set writes v to the file, replacing any existing token. The file is replaced atomically, so a failed write does not leave a partial token, and the directory holding it is created, readable only by its owner, if it does not exist.

type KeyringStore

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

KeyringStore is a Store that keeps the token in the system keyring (such as Windows Credential Manager, macOS Keychain or the Secret Service on Linux) under an entry for the current user.

func NewKeyringStore

func NewKeyringStore() (*KeyringStore, error)

NewKeyringStore creates a KeyringStore for the current user

func (*KeyringStore) Delete

func (s *KeyringStore) Delete() error

Delete removes the token from the keyring. Nothing is done if the keyring holds no token.

func (*KeyringStore) Get

func (s *KeyringStore) Get() string

Get returns the token from the keyring, or an empty string if there is none or the keyring could not be read

func (*KeyringStore) Set

func (s *KeyringStore) Set(v string) error

Set stores v in the keyring, replacing any existing token

type Store

type Store interface {
	// Delete removes the stored token. Deleting when no token is stored is
	// not an error.
	Delete() error
	// Get returns the stored token, or an empty string if no token is
	// stored or it could not be read.
	Get() string
	// Set stores v, replacing any existing token.
	Set(v string) error
}

Store persists a single refresh token

Jump to

Keyboard shortcuts

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