secrets

package
v0.115.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package secrets keeps account passwords out of the database: in the OS keychain (macOS Keychain, Windows Credential Manager, Secret Service).

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("secret not found")

ErrNotFound is returned when no secret is stored for an account.

Functions

This section is empty.

Types

type Fallback

type Fallback struct {
	Primary Store
	File    *File
}

Fallback keeps secrets in the OS keychain and, where there is none (a Linux box without a Secret Service), in a file only this user can read.

func (Fallback) Delete

func (f Fallback) Delete(id int64) error

Delete removes from both.

func (Fallback) Get

func (f Fallback) Get(id int64) (string, error)

Get reads from the keychain, then the file.

func (Fallback) Set

func (f Fallback) Set(id int64, secret string) error

Set writes to the keychain, or to the file when the keychain refuses.

type File

type File struct {
	Path string
	// contains filtered or unexported fields
}

File is a JSON map of secrets in a 0600 file.

func (*File) Delete

func (f *File) Delete(id int64) error

Delete removes a secret.

func (*File) Get

func (f *File) Get(id int64) (string, error)

Get reads a secret.

func (*File) Set

func (f *File) Set(id int64, secret string) error

Set writes a secret.

type Keychain

type Keychain struct{}

Keychain is the OS keychain.

func (Keychain) Delete

func (Keychain) Delete(id int64) error

Delete removes a secret; a missing one is not an error.

func (Keychain) Get

func (Keychain) Get(id int64) (string, error)

Get reads a secret.

func (Keychain) Set

func (Keychain) Set(id int64, secret string) error

Set writes a secret.

type Memory

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

Memory is an in-process store for tests and previews; it never touches the OS.

func (*Memory) Delete

func (m *Memory) Delete(id int64) error

Delete removes a secret.

func (*Memory) Get

func (m *Memory) Get(id int64) (string, error)

Get reads a secret.

func (*Memory) Set

func (m *Memory) Set(id int64, secret string) error

Set writes a secret.

type Store

type Store interface {
	Get(accountID int64) (string, error)
	Set(accountID int64, secret string) error
	Delete(accountID int64) error
}

Store keeps one secret per account.

Jump to

Keyboard shortcuts

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