credstore

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Overview

Package credstore keeps passwords in the OS credential store, or in a file when no OS store is available.

Index

Constants

View Source
const EnvStore = "OPENARCH_CREDENTIAL_STORE"

EnvStore forces a backend: keychain or file.

View Source
const Service = "openarch"

Service is the label of the entries in the OS store.

Variables

View Source
var ErrNotFound = errors.New("no stored password")

ErrNotFound means the store has no password for the URL and user.

Functions

This section is empty.

Types

type File

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

File keeps passwords in a JSON file with mode 0600.

func (*File) Delete

func (f *File) Delete(url, user string) error

func (*File) Get

func (f *File) Get(url, user string) (string, error)

func (*File) Name

func (f *File) Name() string

func (*File) Set

func (f *File) Set(url, user, secret string) error

type Keychain

type Keychain struct{}

Keychain uses the OS store: Keychain on macOS, Credential Manager on Windows, Secret Service over D-Bus on Linux.

func (Keychain) Delete

func (Keychain) Delete(url, user string) error

func (Keychain) Get

func (Keychain) Get(url, user string) (string, error)

func (Keychain) Name

func (Keychain) Name() string

func (Keychain) Set

func (Keychain) Set(url, user, secret string) error

type Memory

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

Memory is a store for tests.

func (*Memory) Delete

func (m *Memory) Delete(url, user string) error

func (*Memory) Get

func (m *Memory) Get(url, user string) (string, error)

func (*Memory) Name

func (m *Memory) Name() string

func (*Memory) Set

func (m *Memory) Set(url, user, secret string) error

type Store

type Store interface {
	Get(url, user string) (string, error)
	Set(url, user, secret string) error
	Delete(url, user string) error
	// Name is "keychain", "file" or "memory".
	Name() string
}

Store keeps one password per URL and user.

func Open

func Open(configDir string, getenv func(string) string, warn func(string)) (Store, error)

Open returns the store to use. It is the OS store when it works, else the file store. warn is called when the file store replaces the OS store. OPENARCH_CREDENTIAL_STORE=keychain|file forces a backend.

Jump to

Keyboard shortcuts

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