keyring

package
v1.0.48490 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("password not found in keyring")

	// ErrUnavailable indicates the OS keyring backend cannot be reached (for
	// example a headless Linux/CI host with no D-Bus session bus). Callers
	// should treat secure storage as absent and fall back to the config file.
	ErrUnavailable = errors.New("keyring unavailable")

	// ErrAccessDenied is a specific ErrUnavailable: the session bus exists but
	// the sandbox or D-Bus policy refused the connection — most commonly a
	// strict snap whose password-manager-service interface is not connected.
	// Unlike a missing provider, this is something the user can fix, so callers
	// may surface a hint. It wraps ErrUnavailable so the file-storage fallback
	// still triggers.
	ErrAccessDenied = fmt.Errorf("%w: access to the secret service was denied", ErrUnavailable)
)

Functions

func Available

func Available() bool

Available reports whether the OS keyring backend is usable.

On Unix the backend talks to the Secret Service over D-Bus. When no session bus is advertised, the underlying library shells out to "dbus-launch" to start one; on headless/CI machines that binary is absent and the call fails with a confusing `exec: "dbus-launch": executable file not found in $PATH`. We detect that situation up front so we never attempt the operation — and so the load path doesn't pay a doomed 3s timeout on every command.

macOS (Keychain) and Windows (Credential Manager) have no such dependency and are always considered available.

func Delete

func Delete(ctx context.Context, service, user string) error

func Get

func Get(ctx context.Context, service, user string) (password string, err error)

func Set

func Set(ctx context.Context, service, user, password string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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