Skip to content

Providers

Providers are pluggable storage backends that handle the storage and retrieval of secrets. They allow the same secretspec.toml to work across development machines, CI/CD pipelines, and production environments.

ProviderDescriptionReadWriteEncrypted
keyringSystem credential storage (macOS Keychain, Windows Credential Manager, Linux Secret Service)
dotenvTraditional .env file in your project directory
envRead-only access to existing environment variables
onepasswordIntegration with OnePassword password manager
lastpassIntegration with LastPass password manager

SecretSpec determines which provider to use in this order:

  1. Per-secret providers: providers field in secretspec.toml (highest priority, with fallback chain)
  2. CLI flag: secretspec --provider flag
  3. Environment: SECRETSPEC_PROVIDER
  4. Global default: Default provider in user config set via secretspec config init

Set your default provider:

Terminal window
$ secretspec config init

Override for specific commands:

Terminal window
# Use dotenv for this command
$ secretspec run --provider dotenv -- npm start
# Set for shell session
$ export SECRETSPEC_PROVIDER=env
$ secretspec check

Configure providers with URIs:

~/.config/secretspec/config.toml
[defaults]
provider = "keyring"
profile = "development" # optional default profile

You can use provider URIs for more specific configuration:

Terminal window
# Use a specific OnePassword vault
$ secretspec run --provider "onepassword://Personal/Development" -- npm start
# Use a specific dotenv file
$ secretspec run --provider "dotenv:/home/user/work/.env" -- npm test

For fine-grained control, you can specify different providers for individual secrets using the providers field in secretspec.toml. This enables fallback chains where secrets are retrieved from multiple providers in order of preference:

[profiles.production]
DATABASE_URL = { description = "Production DB", providers = ["prod_vault", "keyring"] }
API_KEY = { description = "API key from env", providers = ["env"] }
SENTRY_DSN = { description = "Error tracking", providers = ["shared_vault", "keyring"] }

Provider aliases are defined in your user configuration file (~/.config/secretspec/config.toml):

[defaults]
provider = "keyring"
[providers]
prod_vault = "onepassword://vault/Production"
shared_vault = "onepassword://vault/Shared"
env = "env://"

When a secret specifies multiple providers, SecretSpec tries each provider in order until it finds the secret:

# Try OnePassword first, then fall back to keyring if not found
DATABASE_URL = { description = "DB", providers = ["prod_vault", "keyring"] }

This enables complex workflows:

  • Shared vs environment-specific: Try a shared vault first, fall back to local keyring
  • Redundancy: Maintain secrets in multiple locations for backup
  • Migration: Gradually move secrets from one provider to another
  • Multi-team setups: Different teams can manage different providers

Use CLI commands to manage provider aliases:

Terminal window
# Add a provider alias
$ secretspec config provider add prod_vault "onepassword://vault/Production"
# List all aliases
$ secretspec config provider list
# Remove an alias
$ secretspec config provider remove prod_vault