credentials

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package credentials resolves the Pipedrive API token from secure storage. The OS keyring (libsecret on Linux, Keychain on macOS, Credential Manager on Windows) is the persistent home; the env var fallback exists for CI, automation, and any environment where the keyring is unavailable (headless SSH, WSL without DBus, containers).

Resolution order (first non-empty wins):

  1. PIPEDRIVE_API_TOKEN env var. Mirrors gh's GH_TOKEN, aws's AWS_ACCESS_KEY_ID, etc. — env explicitly overrides stored credentials so an operator can use a different token without running `pipedrive-mcp login` again.
  2. OS keyring entry under serviceName, account = company domain.

If env is unset and the keyring lookup fails for any reason other than "entry not found" (no DBus, no Secret Service, etc.), the underlying error is returned so the user sees what to fix.

Index

Constants

View Source
const EnvVar = "PIPEDRIVE_API_TOKEN"

EnvVar is the env-var fallback. Documented for CI use.

View Source
const ServiceName = "pipedrive-mcp"

ServiceName is the keyring service identifier. Same value across all platforms; the keyring backend handles platform-specific storage.

Variables

View Source
var ErrNotFound = errors.New("credentials: no token found in keyring or PIPEDRIVE_API_TOKEN")

ErrNotFound is returned when no token is configured anywhere.

Functions

func Delete

func Delete(b Backend, domain string) error

Delete removes the keyring entry for the given domain. No-op if the entry did not exist.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err signals a missing keyring entry (as opposed to the keyring being unavailable entirely).

func Store

func Store(b Backend, domain, token string) error

Store writes the token into the keyring under the given domain. Surrounding whitespace is trimmed before write so the keyring is the single source of truth for the canonical form.

Types

type Backend

type Backend interface {
	Get(service, account string) (string, error)
	Set(service, account, token string) error
	Delete(service, account string) error
}

Backend is the minimal keyring contract this package depends on. Tests substitute an in-memory implementation; production wires it to github.com/zalando/go-keyring.

func Default

func Default() Backend

Default returns the production keyring-backed implementation.

type Source

type Source string

Source identifies which path a resolved token came from. Useful for log fields and tests.

const (
	SourceKeyring Source = "keyring"
	SourceEnv     Source = "env"
)

Source values returned by Resolve.

func Resolve

func Resolve(b Backend, domain string) (string, Source, error)

Resolve looks up the token for the given company domain. Env wins over keyring (matches gh/aws precedence); a missing keyring entry is treated as "fall through", but a broken keyring is surfaced so the user knows to set the env var or fix DBus.

Jump to

Keyboard shortcuts

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