credentials

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package credentials provides secure credential storage for API keys and tokens.

Package credentials provides secure credential storage for API keys and tokens.

Package credentials provides secure credential storage for API keys and tokens.

Package credentials provides secure credential storage for API keys and tokens.

Index

Constants

View Source
const (
	KeyOpenAIAPIKey    = "indago.openai_api_key"
	KeyAnthropicAPIKey = "indago.anthropic_api_key"
	KeyOllamaURL       = "indago.ollama_url"
	KeyLMStudioURL     = "indago.lmstudio_url"
	KeyDefaultProvider = "indago.default_provider"
	KeyCallbackURL     = "indago.callback_url"
)

Well-known credential keys

Variables

View Source
var (
	ErrNotFound     = errors.New("credential not found")
	ErrNotSupported = errors.New("credential storage not supported on this platform")
	ErrAccessDenied = errors.New("access denied to credential store")
	ErrInvalidKey   = errors.New("invalid credential key")
	ErrStoreFailed  = errors.New("failed to store credential")
	ErrDeleteFailed = errors.New("failed to delete credential")
)

Common errors

Functions

This section is empty.

Types

type Credential

type Credential struct {
	Key         string `json:"key"`
	Description string `json:"description,omitempty"`
	CreatedAt   string `json:"created_at,omitempty"`
	UpdatedAt   string `json:"updated_at,omitempty"`
}

Credential represents a stored credential with metadata.

type EncryptedFileStore

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

EncryptedFileStore implements credential storage using an encrypted file.

func NewEncryptedFileStore

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

NewEncryptedFileStore creates a new encrypted file credential store.

func (*EncryptedFileStore) Available

func (e *EncryptedFileStore) Available() bool

Available always returns true as file storage is always available.

func (*EncryptedFileStore) Delete

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

Delete removes a credential from the encrypted file.

func (*EncryptedFileStore) Get

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

Get retrieves a credential from the encrypted file.

func (*EncryptedFileStore) List

func (e *EncryptedFileStore) List() ([]string, error)

List returns all credential keys from the encrypted file.

func (*EncryptedFileStore) Name

func (e *EncryptedFileStore) Name() string

Name returns the store backend name.

func (*EncryptedFileStore) Path

func (e *EncryptedFileStore) Path() string

Path returns the path to the credential file.

func (*EncryptedFileStore) Set

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

Set stores a credential in the encrypted file.

type KeychainStore

type KeychainStore struct{}

KeychainStore is a stub for non-darwin platforms.

func NewKeychainStore

func NewKeychainStore() *KeychainStore

NewKeychainStore returns nil on non-darwin platforms.

func (*KeychainStore) Available

func (k *KeychainStore) Available() bool

Available returns false on non-darwin platforms.

func (*KeychainStore) Delete

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

Delete is not available on non-darwin platforms.

func (*KeychainStore) Get

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

Get is not available on non-darwin platforms.

func (*KeychainStore) List

func (k *KeychainStore) List() ([]string, error)

List is not available on non-darwin platforms.

func (*KeychainStore) Name

func (k *KeychainStore) Name() string

Name returns the store backend name.

func (*KeychainStore) Set

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

Set is not available on non-darwin platforms.

type Manager

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

Manager manages credential storage with fallback support.

func NewManager

func NewManager() (*Manager, error)

NewManager creates a credential manager with platform-appropriate backends.

func NewManagerWithStore

func NewManagerWithStore(store Store) *Manager

NewManagerWithStore creates a manager with a specific store.

func (*Manager) Delete

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

Delete removes a credential from all stores.

func (*Manager) Get

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

Get retrieves a credential, checking all stores.

func (*Manager) GetProviderAPIKey

func (m *Manager) GetProviderAPIKey(provider string) (string, error)

GetProviderAPIKey retrieves the API key for a given provider.

func (*Manager) List

func (m *Manager) List() ([]string, error)

List returns all credential keys from all stores.

func (*Manager) Set

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

Set stores a credential using the primary store.

func (*Manager) SetProviderAPIKey

func (m *Manager) SetProviderAPIKey(provider, apiKey string) error

SetProviderAPIKey stores the API key for a given provider.

func (*Manager) StoreName

func (m *Manager) StoreName() string

StoreName returns the name of the primary store being used.

type SecretServiceStore

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

SecretServiceStore implements credential storage using Linux Secret Service (via secret-tool).

func NewSecretServiceStore

func NewSecretServiceStore() *SecretServiceStore

NewSecretServiceStore creates a new Linux Secret Service credential store.

func (*SecretServiceStore) Available

func (s *SecretServiceStore) Available() bool

Available returns true if secret-tool is available.

func (*SecretServiceStore) Delete

func (s *SecretServiceStore) Delete(key string) error

Delete removes a credential using secret-tool.

func (*SecretServiceStore) Get

func (s *SecretServiceStore) Get(key string) (string, error)

Get retrieves a credential using secret-tool.

func (*SecretServiceStore) List

func (s *SecretServiceStore) List() ([]string, error)

List returns all credential keys from Secret Service. Note: secret-tool doesn't have a built-in list command, so this is limited.

func (*SecretServiceStore) Name

func (s *SecretServiceStore) Name() string

Name returns the store backend name.

func (*SecretServiceStore) Set

func (s *SecretServiceStore) Set(key, value string) error

Set stores a credential using secret-tool.

type Store

type Store interface {
	// Set stores a credential with the given key.
	Set(key, value string) error

	// Get retrieves a credential by key.
	Get(key string) (string, error)

	// Delete removes a credential by key.
	Delete(key string) error

	// List returns all credential keys.
	List() ([]string, error)

	// Name returns the store backend name.
	Name() string

	// Available returns true if this store is available on the current system.
	Available() bool
}

Store is the interface for credential storage backends.

Jump to

Keyboard shortcuts

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