keychain

package
v3.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package keychain implements a native secure password store for each platform.

Index

Constants

View Source
const (
	Pass              = "pass-app"
	SecretService     = "secret-service"
	SecretServiceDBus = "secret-service-dbus"
)
View Source
const Version = "k11"

Version is the keychain data version.

Variables

View Source
var (
	// ErrNoKeychain indicates that no suitable keychain implementation could be loaded.
	ErrNoKeychain = errors.New("no keychain") //nolint:gochecknoglobals

	// ErrMacKeychainRebuild is returned on macOS with blocked or corrupted keychain.
	ErrMacKeychainRebuild = errors.New("keychain error -25293")

	ErrKeychainNoItem = errors.New("no such keychain item")
)

Functions

func IsErrKeychainNoItem added in v3.9.0

func IsErrKeychainNoItem(err error) bool

Types

type Helpers

type Helpers map[string]helperConstructor

type Keychain

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

func NewKeychain

func NewKeychain(preferred, keychainName string, helpers Helpers, defaultHelper string) (*Keychain, error)

NewKeychain creates a new native keychain.

func NewMissingKeychain

func NewMissingKeychain() *Keychain

NewMissingKeychain returns a new keychain that always returns an error.

func (*Keychain) Clear

func (kc *Keychain) Clear() error

func (*Keychain) Delete

func (kc *Keychain) Delete(userID string) error

func (*Keychain) Get

func (kc *Keychain) Get(userID string) (string, string, error)

Get returns the username and secret for the given userID.

func (*Keychain) List

func (kc *Keychain) List() ([]string, error)

func (*Keychain) Put

func (kc *Keychain) Put(userID, secret string) error

type List added in v3.7.1

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

func NewList added in v3.7.1

func NewList() *List

NewList checks availability of every keychains detected on the User Operating System This will ask the user to unlock keychain(s) to check their usability. This should only be called once.

func NewTestKeychainsList added in v3.7.1

func NewTestKeychainsList() *List

func (*List) GetDefaultHelper added in v3.7.1

func (kcl *List) GetDefaultHelper() string

func (*List) GetHelpers added in v3.7.1

func (kcl *List) GetHelpers() Helpers

type SecretServiceDBusHelper

type SecretServiceDBusHelper struct{}

SecretServiceDBusHelper is wrapper around keybase/go-keychain/secretservice library.

func (*SecretServiceDBusHelper) Add

Add appends credentials to the store.

func (*SecretServiceDBusHelper) Delete

func (s *SecretServiceDBusHelper) Delete(serverURL string) error

Delete removes credentials from the store.

func (*SecretServiceDBusHelper) Get

func (s *SecretServiceDBusHelper) Get(serverURL string) (string, string, error)

Get retrieves credentials from the store. It returns username and secret as strings.

func (*SecretServiceDBusHelper) List

func (s *SecretServiceDBusHelper) List() (map[string]string, error)

List returns the stored serverURLs and their associated usernames.

type TestHelper added in v3.0.7

type TestHelper map[string]*credentials.Credentials

func NewTestHelper added in v3.0.7

func NewTestHelper() TestHelper

func (TestHelper) Add added in v3.0.7

func (h TestHelper) Add(creds *credentials.Credentials) error

func (TestHelper) Delete added in v3.0.7

func (h TestHelper) Delete(url string) error

func (TestHelper) Get added in v3.0.7

func (h TestHelper) Get(url string) (string, string, error)

func (TestHelper) List added in v3.0.7

func (h TestHelper) List() (map[string]string, error)

Jump to

Keyboard shortcuts

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