secrets

package
v0.8.20 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package secrets stores small dejima-held secrets (webhook HMAC keys and the like) at rest in the OS keychain when one is available — the macOS login Keychain via `security`, or the Secret Service (libsecret) via `secret-tool` on Linux — and falls back to a 0600 file under ~/.dejima/secrets otherwise.

The fallback is deliberate, not a failure mode: a `--system` daemon starts at boot *before any login*, when the login keychain is still locked, so a keychain write/read can fail until someone logs in once. Rather than hard-fail (the trap the roadmap calls out — reporting "never configured" when the keychain is merely locked), every operation degrades to the file store. So a secret set while the keychain was locked lands in the file and is still readable; secrets set while unlocked live in the keychain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store reads/writes secrets, preferring the OS keychain and falling back to a file. It's safe for concurrent use.

func Open

func Open() (*Store, error)

Open builds a Store: the platform keychain backend if its CLI is on PATH, plus the always-available file fallback.

func (*Store) Backend

func (s *Store) Backend() string

Backend names the active keychain backend ("macos-keychain", "secret-service", or "file" when no keychain is usable) — for diagnostics.

func (*Store) Delete

func (s *Store) Delete(account string) error

Delete removes the secret from both backends (best-effort on the keychain).

func (*Store) Get

func (s *Store) Get(account string) (string, bool, error)

Get returns the secret for account. It prefers the keychain; on a miss, a locked keychain, or any keychain error it falls through to the file store, so a secret written under either backend is found.

func (*Store) Set

func (s *Store) Set(account, value string) error

Set stores the secret. It writes the keychain when one is usable (and clears any stale file copy so the keychain stays authoritative); if the keychain is unavailable or locked, it writes the file fallback instead.

Jump to

Keyboard shortcuts

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