keychain

package
v0.0.0-...-f6f491c Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package keychain implements a vault.Store backed by the operating system keychain via go-keyring. On macOS this uses Keychain, on Linux the Secret Service API, and on Windows the Credential Manager.

An index entry is maintained alongside stored values so that Store.List works across all platforms. The index is stored under a reserved key within the same keyring service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Store)

Option configures a keychain Store.

func WithService

func WithService(name string) Option

WithService overrides the default keyring service name ("vault").

type Store

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

Store is a vault.Store backed by the system keychain. It implements vault.Namespaced — calling Store.WithNamespace returns a store scoped to a different keyring service name.

func New

func New(opts ...Option) *Store

New creates a keychain-backed store.

func (*Store) Delete

func (s *Store) Delete(_ context.Context, key string) error

Delete removes an entry from the keychain and updates the key index.

func (*Store) Get

func (s *Store) Get(_ context.Context, key string) (vault.Entry, error)

Get retrieves an entry by key from the keychain.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]vault.Entry, error)

List returns all entries stored in the keychain by reading the key index and fetching each entry individually.

func (*Store) Set

func (s *Store) Set(_ context.Context, entry vault.Entry) error

Set stores an entry in the keychain and updates the key index.

func (*Store) WithNamespace

func (s *Store) WithNamespace(ns string) vault.Store

WithNamespace returns a vault.Store scoped to the given namespace. The namespace is appended to the service name (e.g. "vault/prod").

Jump to

Keyboard shortcuts

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