keyring

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package keyring provides secure credential storage using the OS keychain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSecretStore

func NewSecretStore(configDir string) (ports.SecretStore, error)

NewSecretStore creates a SecretStore, preferring system keyring with file fallback. If the system keyring is available but empty, and the encrypted file has credentials, it will migrate the credentials to the system keyring.

Types

type EncryptedFileStore

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

EncryptedFileStore implements SecretStore using an encrypted file. This is a fallback for environments where the system keyring is unavailable. Uses AES-256-GCM encryption with a machine-specific key.

func NewEncryptedFileStore

func NewEncryptedFileStore(configDir string) (*EncryptedFileStore, error)

NewEncryptedFileStore creates a new EncryptedFileStore. The secrets are stored in an encrypted file within the config directory.

func (*EncryptedFileStore) Delete

func (f *EncryptedFileStore) Delete(key string) error

Delete removes a secret for the given key.

func (*EncryptedFileStore) Get

func (f *EncryptedFileStore) Get(key string) (string, error)

Get retrieves a secret value for the given key.

func (*EncryptedFileStore) IsAvailable

func (f *EncryptedFileStore) IsAvailable() bool

IsAvailable always returns true for file-based storage.

func (*EncryptedFileStore) Name

func (f *EncryptedFileStore) Name() string

Name returns the name of the secret store backend.

func (*EncryptedFileStore) Set

func (f *EncryptedFileStore) Set(key, value string) error

Set stores a secret value for the given key.

type GrantStore

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

GrantStore implements ports.GrantStore using a SecretStore backend.

func NewGrantStore

func NewGrantStore(secrets ports.SecretStore) *GrantStore

NewGrantStore creates a new GrantStore.

func (*GrantStore) ClearGrants

func (g *GrantStore) ClearGrants() error

ClearGrants removes all grants from storage.

func (*GrantStore) DeleteGrant

func (g *GrantStore) DeleteGrant(grantID string) error

DeleteGrant removes a grant from storage.

func (*GrantStore) GetDefaultGrant

func (g *GrantStore) GetDefaultGrant() (string, error)

GetDefaultGrant returns the default grant ID.

func (*GrantStore) GetGrant

func (g *GrantStore) GetGrant(grantID string) (*domain.GrantInfo, error)

GetGrant retrieves grant info by ID.

func (*GrantStore) GetGrantByEmail

func (g *GrantStore) GetGrantByEmail(email string) (*domain.GrantInfo, error)

GetGrantByEmail retrieves grant info by email.

func (*GrantStore) ListGrants

func (g *GrantStore) ListGrants() ([]domain.GrantInfo, error)

ListGrants returns all stored grants.

func (*GrantStore) SaveGrant

func (g *GrantStore) SaveGrant(info domain.GrantInfo) error

SaveGrant saves grant info to storage.

func (*GrantStore) SetDefaultGrant

func (g *GrantStore) SetDefaultGrant(grantID string) error

SetDefaultGrant sets the default grant ID.

type MockSecretStore

type MockSecretStore struct {

	// Custom functions for testing specific behaviors
	SetFunc    func(key, value string) error
	GetFunc    func(key string) (string, error)
	DeleteFunc func(key string) error
	// contains filtered or unexported fields
}

MockSecretStore is a mock implementation of SecretStore for testing.

func NewMockSecretStore

func NewMockSecretStore() *MockSecretStore

NewMockSecretStore creates a new MockSecretStore.

func (*MockSecretStore) Delete

func (m *MockSecretStore) Delete(key string) error

Delete removes a secret for the given key.

func (*MockSecretStore) Get

func (m *MockSecretStore) Get(key string) (string, error)

Get retrieves a secret value for the given key.

func (*MockSecretStore) GetAll

func (m *MockSecretStore) GetAll() map[string]string

GetAll returns all stored secrets.

func (*MockSecretStore) IsAvailable

func (m *MockSecretStore) IsAvailable() bool

IsAvailable returns whether the mock is available.

func (*MockSecretStore) Name

func (m *MockSecretStore) Name() string

Name returns the name of the secret store backend.

func (*MockSecretStore) Reset

func (m *MockSecretStore) Reset()

Reset clears all secrets.

func (*MockSecretStore) Set

func (m *MockSecretStore) Set(key, value string) error

Set stores a secret value for the given key.

func (*MockSecretStore) SetAvailable

func (m *MockSecretStore) SetAvailable(available bool)

SetAvailable sets whether the mock is available.

type SystemKeyring

type SystemKeyring struct{}

SystemKeyring implements SecretStore using the system keychain.

func NewSystemKeyring

func NewSystemKeyring() *SystemKeyring

NewSystemKeyring creates a new SystemKeyring instance.

func (*SystemKeyring) Delete

func (k *SystemKeyring) Delete(key string) error

Delete removes a secret for the given key.

func (*SystemKeyring) Get

func (k *SystemKeyring) Get(key string) (string, error)

Get retrieves a secret value for the given key.

func (*SystemKeyring) IsAvailable

func (k *SystemKeyring) IsAvailable() bool

IsAvailable checks if the system keychain is available.

func (*SystemKeyring) Name

func (k *SystemKeyring) Name() string

Name returns the name of the secret store backend.

func (*SystemKeyring) Set

func (k *SystemKeyring) Set(key, value string) error

Set stores a secret value for the given key.

Jump to

Keyboard shortcuts

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