macOS Keychain
The built-in keychain() resolver lets you load secrets directly from the macOS Keychain using declarative instructions in your .env files. It communicates with the Keychain through Varlock’s native Swift daemon, which enforces biometric authentication (Touch ID) and per-session access control.
Features
Section titled “Features”- Built-in — No plugin or extra dependency needed
- Biometric gating — Access is protected by Touch ID via Varlock’s native daemon
- Interactive picker — Use
keychain(prompt)to browse and select items via a native dialog - Auto-write-back — Prompt mode writes the resolved reference back to your config file
- Named or positional syntax — Flexible argument styles for quick or precise lookups
- Field selection — Extract specific fields from keychain items
- Multiple keychain support — Access the login, System, or custom keychains
Getting started
Section titled “Getting started”Rather than wiring up items individually, the easiest way to get started is by using keychain(prompt). This will open a native picker dialog where you can select existing keychain items, or create new ones. After selection, Varlock will automatically write the resolved reference back into your config file for future use.
ITEM=keychain(prompt) # Opens a native picker dialogReference
Section titled “Reference”keychain()
Section titled “keychain()”Fetch a secret from the macOS Keychain. Communicates with the Keychain through Varlock’s native daemon, which enforces biometric (Touch ID) authentication.
Array args:
service(optional): Service name of the keychain item (positional shorthand)prompt(optional): Enter interactive picker mode
Key/value args:
service(optional): Service name of the keychain itemaccount(optional): Account identifier for the keychain itemkeychain(optional): Name of a specific keychain to search (e.g.,"System")field(optional): Specific field to extract from the keychain itemprompt(optional): If set, opens a native picker dialog for interactive selection
# Positional shorthandDATABASE_PASSWORD=keychain("com.company.database")
# Named service paramAPI_KEY=keychain(service="com.company.api")
# With accountADMIN_PW=keychain("com.company.db", account="admin")
# Targeting a specific keychainCERT=keychain("com.company.cert", keychain="System")
# Field selectionTOKEN=keychain("com.company.auth", field="password")
# Interactive picker modeNEW_SECRET=keychain(prompt)Troubleshooting
Section titled “Troubleshooting””keychain() is only supported on macOS”
Section titled “”keychain() is only supported on macOS””This resolver requires macOS. It is not available on Linux or Windows. If you need cross-platform secret management, consider using one of the plugin-based secret sources.
Failed to read keychain item
Section titled “Failed to read keychain item”- Verify the item exists in Keychain Access.app
- Check that the service name and account match exactly
- Try
keychain(prompt)to browse available items and grant VarlockEnclave access via the native dialog
Selection was cancelled
Section titled “Selection was cancelled”If you dismiss the native picker without selecting an item, the resolution will fail. Run varlock again to retry, or replace keychain(prompt) with an explicit keychain(service="...") reference.
VarlockEnclave access
Section titled “VarlockEnclave access”The first time you access a keychain item through Varlock, macOS may prompt you to grant access to VarlockEnclave. Approve this to allow future reads. If you accidentally denied access, you can update the item’s Access Control settings in Keychain Access.app.