secrets

package
v2.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package secrets provides an optional, opt-in abstraction over the OS keyring for storing user credentials. All operations degrade gracefully when the keyring backend is unavailable (headless CI, no D-Bus, locked keychain) so the CLI never aborts or hangs because of it.

Index

Constants

View Source
const (
	FieldAPIKey   = "apikey"
	FieldPassword = "password"
)

Field names for the two secrets that may live in the keyring.

View Source
const Service = "redmine-cli"

Service is the keyring service name used for all redmine-cli secrets.

Variables

This section is empty.

Functions

func Disabled

func Disabled() bool

Disabled reports whether REDMINE_NO_KEYRING hard-disables all keyring access. Callers skipping cleanup because of it should warn the user that the stored credential remains.

Types

type Store

type Store interface {
	// Get returns the stored secret. ok is false with a nil error when nothing
	// is stored; err is only non-nil for a real backend failure.
	Get(profile, field string) (secret string, ok bool, err error)
	Set(profile, field, secret string) error
	Delete(profile, field string) error
	// Available reports, best-effort, whether the keyring backend is usable on
	// this machine.
	Available() bool
}

Store abstracts credential storage so the keyring backend can be swapped for an in-memory fake in tests.

var Default Store = keyringStore{}

Default is the process-wide Store. Tests may reassign it to substitute a fake, or call keyring.MockInit to redirect the real backend in memory.

Jump to

Keyboard shortcuts

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