fnox 1.25.1

A flexible secret management tool supporting multiple providers and encryption methods
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# Configuration Reference

Complete reference for the `fnox.toml` configuration file.

## JSON Schema

A JSON Schema is available for IDE autocompletion and validation:

```
https://fnox.jdx.dev/schema.json
```

### Editor Setup

**VS Code** with [Even Better TOML](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml):

```toml
#:schema https://fnox.jdx.dev/schema.json

[providers]
age = { type = "age", recipients = ["age1..."] }
```

**JetBrains IDEs**: Add the schema URL in Settings > Languages & Frameworks > Schemas and DTDs > JSON Schema Mappings.

## File Location

fnox looks for configuration files in this order (lowest to highest priority):

1. **Global config**: `~/.config/fnox/config.toml` (or `$FNOX_CONFIG_DIR/config.toml`)
2. `fnox.toml` in parent directories (hierarchical search)
3. `fnox.toml` in current directory
4. `fnox.$FNOX_PROFILE.toml` alongside each `fnox.toml` (profile-specific)
5. `fnox.local.toml` alongside each `fnox.toml` (for local overrides)
6. Path specified via `-c, --config` flag

### Global Configuration

The global config file stores machine-wide secrets and providers that apply to all projects:

```bash
# Initialize global config
fnox init --global

# Add secrets to global config
fnox set MY_TOKEN "secret-value" --global

# Add providers to global config
fnox provider add aws aws-sm --global
```

**Location**: `~/.config/fnox/config.toml` (customizable via `FNOX_CONFIG_DIR`)

**Use cases**:

- Personal API tokens used across multiple projects
- Machine-specific credentials
- Default providers available everywhere

## Basic Structure

```toml
# Top-level settings
if_missing = "warn"  # Global default for missing secrets
import = ["./shared/secrets.toml"]  # Import other configs

# Provider definitions
[providers]
PROVIDER_NAME = { type = "PROVIDER_TYPE" }  # ... provider-specific config ...

# Secret definitions
[secrets]
SECRET_NAME = { provider = "PROVIDER_NAME", value = "...", default = "...", if_missing = "error", description = "..." }

# Profile definitions
[profiles.PROFILE_NAME]
# ... same structure as top-level ...
```

## Top-Level Settings

### `if_missing`

Global default behavior when secrets cannot be resolved.

```toml
if_missing = "error"  # or "warn", "ignore"
```

**Values:**

- `"error"` - Fail if secret is missing
- `"warn"` - Print warning and continue (default)
- `"ignore"` - Silently skip missing secrets

**Priority:** Lowest (overridden by secret-level, env vars, CLI flags).

### `imports`

List of config files to import.

```toml
import = ["./shared/base.toml", "./envs/dev.toml"]
```

**Usage:**

- Paths relative to current config file
- Imported files merged into current config
- Later imports override earlier ones

## Provider Configuration

```toml
[providers.PROVIDER_NAME]
type = "PROVIDER_TYPE"
# ... provider-specific fields ...
```

### `auth_command`

Override the authentication command for a specific provider instance. When provider authentication fails in a TTY, fnox prompts to run this command. By default, each provider type has a built-in auth command (e.g., `bw login` for Bitwarden, `op signin` for 1Password).

```toml
[providers]
# Use rbw instead of the default bw CLI
rbw = { type = "bitwarden", backend = "rbw", auth_command = "rbw unlock" }

# Use a custom AWS SSO profile
aws = { type = "aws-sm", region = "us-east-1", auth_command = "aws sso login --profile myprofile" }

# Disable auth prompting for this provider
vault = { type = "vault", address = "https://vault.example.com", auth_command = "" }
```

Setting `auth_command = ""` disables the auth prompt for that provider instance.

### Common Provider Types

#### Age Encryption

```toml
[providers.age]
type = "age"
recipients = [
  "age1ql3z7hjy54pw3hyww5ayyfg7zqgvc7w3j2elw8zmrj2kg5sfn9aqmcac8p",
  "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGQs..."
]
```

#### AWS Secrets Manager

```toml
[providers]
aws = { type = "aws-sm", region = "us-east-1", prefix = "myapp/" }  # prefix is optional
```

#### AWS KMS

```toml
[providers]
kms = { type = "aws-kms", key_id = "arn:aws:kms:us-east-1:123456789012:key/...", region = "us-east-1" }
```

#### Azure Key Vault Secrets

```toml
[providers]
azure = { type = "azure-sm", vault_url = "https://myapp-vault.vault.azure.net/", prefix = "myapp/" }  # prefix is optional
```

#### Azure Key Vault Keys

```toml
[providers]
azurekms = { type = "azure-kms", vault_url = "https://myapp-vault.vault.azure.net/", key_name = "encryption-key" }
```

#### GCP Secret Manager

```toml
[providers]
gcp = { type = "gcp-sm", project = "my-project-id", prefix = "myapp/" }  # prefix is optional
```

#### GCP Cloud KMS

```toml
[providers.gcpkms]
type = "gcp-kms"
project = "my-project-id"
location = "us-central1"
keyring = "fnox-keyring"
key = "fnox-key"
```

#### 1Password

```toml
[providers]
onepass = { type = "1password", vault = "Development", account = "my.1password.com" }  # account is optional
```

#### Bitwarden

```toml
[providers]
bitwarden = { type = "bitwarden", collection = "collection-id", organization_id = "org-id" }  # both optional
```

#### HashiCorp Vault

```toml
[providers]
vault = { type = "vault", address = "https://vault.example.com:8200", path = "secret/myapp", token = "hvs.CAESIJ..." }  # token optional, can use VAULT_TOKEN env var
```

#### OS Keychain

```toml
[providers]
keychain = { type = "keychain", service = "fnox", prefix = "myapp/" }  # prefix is optional
```

## Secret Configuration

```toml
[secrets]
SECRET_NAME = { provider = "PROVIDER_NAME", value = "...", default = "...", if_missing = "error", description = "..." }
```

### Fields

#### `provider`

Provider to use for this secret.

```toml
[secrets]
DATABASE_URL = { provider = "age", value = "encrypted..." }
```

**Required:** Unless using only `default` (plain text).

#### `value`

Provider-specific value:

- **Encryption providers** (age, aws-kms, etc.): Encrypted ciphertext
- **Remote providers** (aws-sm, 1password, etc.): Secret name/reference

```toml
[secrets]
# Encrypted ciphertext (age)
DATABASE_URL = { provider = "age", value = "YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNjcnlwdC..." }

# Remote reference (AWS)
DATABASE_URL = { provider = "aws", value = "database-url" }  # Secret name in AWS Secrets Manager
```

#### `default`

Fallback value if secret cannot be resolved.

```toml
[secrets]
DATABASE_URL = { provider = "age", value = "encrypted...", default = "postgresql://localhost/dev" }  # Fallback for local dev
```

**Use for:**

- Non-sensitive defaults
- Local development fallbacks
- Optional configuration

#### `if_missing`

Behavior when secret cannot be resolved.

```toml
[secrets]
DATABASE_URL = { provider = "aws", value = "database-url", if_missing = "error" }  # Fail if missing (critical secret)
ANALYTICS_KEY = { provider = "aws", value = "analytics-key", if_missing = "ignore" }  # Silently skip if missing (optional)
```

**Values:** `"error"`, `"warn"`, `"ignore"`

**Priority:** Overrides top-level `if_missing`, but overridden by env vars and CLI flags.

#### `description`

Human-readable description.

```toml
[secrets]
DATABASE_URL = { provider = "age", value = "encrypted...", description = "Production database connection string" }
```

## Profile Configuration

Profiles allow environment-specific configuration:

```toml
# Default profile (no prefix)
[secrets]
DATABASE_URL = { provider = "age", value = "encrypted-dev..." }

# Production profile
[profiles.production]

[profiles.production.providers]
aws = { type = "aws-sm", region = "us-east-1" }

[profiles.production.secrets]
DATABASE_URL = { provider = "aws", value = "database-url" }
```

### Profile Structure

```toml
[profiles.PROFILE_NAME]
if_missing = "error"  # Profile-specific default

[profiles.PROFILE_NAME.providers]
PROVIDER_NAME = { type = "PROVIDER_TYPE" }  # ... provider config ...

[profiles.PROFILE_NAME.secrets]
SECRET_NAME = { provider = "PROVIDER_NAME", value = "..." }  # ... secret config ...
```

### Profile Inheritance

Profiles inherit top-level secrets and providers:

```toml
# Top-level (inherited by all profiles)
[secrets]
LOG_LEVEL = { default = "info" }
DATABASE_URL = { provider = "age", value = "encrypted-dev..." }

# Production profile
[profiles.production.secrets]
DATABASE_URL = { provider = "aws", value = "prod-db" }  # Overrides top-level DATABASE_URL
# Inherits LOG_LEVEL="info" from top-level
```

You can disable this merge behavior at runtime:

```bash
fnox exec --profile production --no-defaults -- ./deploy.sh
```

With `--no-defaults`, only `[profiles.<name>.secrets]` are used for the selected profile.

## Complete Example

```toml
# Global settings
if_missing = "warn"
import = ["./shared/common.toml"]

# Providers
[providers]
age = { type = "age", recipients = ["age1ql3z7hjy54pw3hyww5ayyfg7zqgvc7w3j2elw8zmrj2kg5sfn9aqmcac8p"] }
aws = { type = "aws-sm", region = "us-east-1", prefix = "myapp/" }

# Default profile secrets
[secrets]
DATABASE_URL = { provider = "age", value = "YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNjcnlwdC...", default = "postgresql://localhost/dev", description = "Database connection string" }
JWT_SECRET = { provider = "age", value = "encrypted...", if_missing = "error" }
LOG_LEVEL = { default = "info" }

# Production profile
[profiles.production]
if_missing = "error"

[profiles.production.providers]
aws = { type = "aws-sm", region = "us-east-1", prefix = "myapp-prod/" }

[profiles.production.secrets]
DATABASE_URL = { provider = "aws", value = "database-url", description = "Production database" }
JWT_SECRET = { provider = "aws", value = "jwt-secret" }
# Inherits LOG_LEVEL from top-level
```

## Local Overrides

Create `fnox.local.toml` alongside `fnox.toml` for local overrides:

```toml
# fnox.local.toml (gitignored)

[secrets]
DATABASE_URL = { default = "postgresql://localhost/mylocal" }  # Override for local development
DEBUG_MODE = { default = "true" }
```

**Important:** Add to `.gitignore`:

```gitignore
fnox.local.toml
```

## Profile-Specific Config Files

You can create environment-specific config files that load based on the `FNOX_PROFILE` environment variable:

```bash
# Directory structure
project/
├── fnox.toml              # Base config
├── fnox.production.toml   # Production overrides
├── fnox.staging.toml      # Staging overrides
├── fnox.development.toml  # Development overrides
└── fnox.local.toml        # Local overrides (gitignored)
```

Example usage:

```bash
# Use default config (fnox.toml only)
fnox exec -- npm start

# Use production config (fnox.toml + fnox.production.toml)
FNOX_PROFILE=production fnox exec -- ./deploy.sh

# Use staging config (fnox.toml + fnox.staging.toml)
FNOX_PROFILE=staging fnox exec -- ./deploy.sh
```

**Key differences:**

- `fnox.$FNOX_PROFILE.toml` files are **committed to git** (environment-specific, but shared with team)
- `fnox.local.toml` is **gitignored** (machine-specific, personal overrides)
- Profile-specific files work with the default profile's secrets, not `[profiles.xxx]` sections
- `fnox.default.toml` is **not loaded** (use `fnox.toml` instead)

## Hierarchical Configuration

fnox searches parent directories for `fnox.toml` files:

```
project/
├── fnox.toml              # Root config
└── services/
    └── api/
        └── fnox.toml      # API config (inherits from root)
```

Merge order (lowest to highest priority):

1. **Global config** (`~/.config/fnox/config.toml`)
2. Root `fnox.toml`
3. Root `fnox.$FNOX_PROFILE.toml` (if `FNOX_PROFILE` is set and not "default")
4. Root `fnox.local.toml`
5. Child `fnox.toml`
6. Child `fnox.$FNOX_PROFILE.toml` (if `FNOX_PROFILE` is set and not "default")
7. Child `fnox.local.toml`

**Note**: Global config is always loaded, even when `root = true` stops parent directory recursion.

## Next Steps

- [CLI Reference]/cli/ - All available commands
- [Environment Variables]/reference/environment - Environment variable reference
- [Providers Overview]/providers/overview - Available providers