store

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package store provides local credential storage for OAuth tokens.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Path is the path to the credentials file.
	// Defaults to a namespaced file in ~/.config/panda/credentials/
	Path string

	// IssuerURL namespaces stored credentials by auth issuer.
	IssuerURL string

	// ClientID namespaces stored credentials by OAuth client.
	ClientID string

	// Resource namespaces stored credentials by requested resource.
	Resource string

	// RefreshBuffer is how long before expiry to refresh the token.
	RefreshBuffer time.Duration

	// RefreshTokenTTL is the expected lifetime of the refresh token.
	// When set, the store will trigger a refresh at 50% of this duration
	// to keep the refresh token alive via provider rotation.
	RefreshTokenTTL time.Duration

	// AuthClient is the OAuth client for refreshing tokens.
	AuthClient client.Client
}

Config configures the credential store.

type Store

type Store interface {
	// Path returns the resolved credentials file path.
	Path() string

	// Save saves tokens to the store.
	Save(tokens *client.Tokens) error

	// Load loads tokens from the store.
	Load() (*client.Tokens, error)

	// Clear removes stored tokens.
	Clear() error

	// GetAccessToken returns a valid access token, refreshing if needed.
	GetAccessToken() (string, error)

	// IsAuthenticated returns true if valid tokens are stored.
	IsAuthenticated() bool
}

Store manages local credential storage.

func New

func New(log logrus.FieldLogger, cfg Config) Store

New creates a new credential store.

Jump to

Keyboard shortcuts

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