You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for secrets stored in authinfo and netrc files
I would like to mamange my ECA config and commands with Guix and don't
want any secrets in those files. I could use keyEnv for this, but all
my other secrets are already in `~/.authinfo.gpg` which I would like
to use.
This PR adds support for reading secrets from the `~/.authinfo` and
`~/.netrc` files. It supports GPG encrypted and Windows variants.
The value of `keyRc` is the machine name to look up in credential files. Supports format: `[login@]machine[:port]`
73
+
74
+
**Benefits:**
75
+
- Secure credential storage (especially with `.authinfo.gpg` encryption)
76
+
- Standardized format used by many Unix tools (curl, git, etc.)
77
+
- Multi-account support via login prefixes
78
+
- Single location for managing credentials across multiple tools
79
+
80
+
See [Credential File Authentication](./models.md#credential-file-authentication) for file formats, GPG encryption setup, and detailed configuration examples.
81
+
55
82
## Tools
56
83
57
84
### MCP
@@ -379,6 +406,7 @@ To configure, add your OTLP collector config via `:otlp` map following [otlp aut
379
406
urlEnv?: string;
380
407
key?: string; // when provider supports api key.
381
408
keyEnv?: string;
409
+
keyRc?: string; // credential file lookup in format [login@]machine[:port]
Copy file name to clipboardExpand all lines: docs/models.md
+165Lines changed: 165 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,171 @@ Example:
50
50
-`OPENAI_API_KEY` for OpenAI
51
51
-`ANTHROPIC_API_KEY` for Anthropic
52
52
53
+
### Credential File Authentication
54
+
55
+
ECA supports reading API credentials from `.authinfo` and `.netrc` files via the `keyRc` configuration, providing a secure and standardized way to manage authentication credentials without storing them in configuration files or environment variables.
56
+
57
+
> **Why "keyRc"?** The name follows the `key*` naming convention (like `key` and `keyEnv`) and references the Unix "rc" (run commands) file tradition. Files like `.bashrc`, `.vimrc`, and `.netrc` use the "rc" suffix to indicate configuration files that are read at startup or runtime.
ECA will automatically decrypt `.authinfo.gpg` or `.netrc.gpg` files using the `gpg` command. Make sure `gpg` is installed and `gpg-agent` is configured for passphrase caching.
158
+
159
+
**GPG Timeout:**
160
+
161
+
GPG decryption has a 30-second timeout by default to prevent hanging on slow or unresponsive GPG processes. You can customize this via the `GPG_TIMEOUT` environment variable (in seconds):
162
+
163
+
```bash
164
+
# Set custom timeout (e.g., 60 seconds)
165
+
export GPG_TIMEOUT=60
166
+
```
167
+
168
+
**Authentication Priority Order:**
169
+
170
+
When resolving credentials, ECA checks sources in this order:
171
+
172
+
1.**Config file** - explicit `key` in provider config (highest priority)
173
+
2.**Credential files** - `keyRc` setting pointing to machine name
174
+
3.**Environment variable** - value from `keyEnv` setting
175
+
4.**OAuth flow** - for providers that support it (e.g., GitHub Copilot)
176
+
177
+
This ensures explicit configuration takes precedence while providing credential files as a convenient option.
178
+
179
+
**Security:**
180
+
181
+
- Plaintext files (`.authinfo`, `.netrc`) should have restricted permissions (0600 on Unix)
182
+
- ECA will warn if permissions are too open
183
+
-`.authinfo.gpg` provides encryption at rest for maximum security
184
+
- Keep credential files out of version control
185
+
- Passwords are never logged or leaked in error messages
186
+
- GPG subprocess has timeout protection (30s default) to prevent hanging
187
+
188
+
**Multi-Account Support:**
189
+
190
+
You can store multiple credentials for the same provider using different login values:
191
+
192
+
```
193
+
machine api.anthropic.com login work password sk-ant-work-...
194
+
machine api.anthropic.com login personal password sk-ant-personal-...
0 commit comments