Skip to content

Commit af20cd2

Browse files
committed
docs: add multi environment encryption
1 parent bd8e1e9 commit af20cd2

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed

docs/guide/intro/encryption.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ npx @app-config/cli secret trust ./my-key
8080
This will re-sign all encryption keys of the current repository with their public
8181
key. This gives them access to any previously encrypted secrets as well.
8282

83+
To specify an encryption environment to trust the user on, set the standard App-Config environment variables (`ENV`, `NODE_ENV`, or `APP_CONFIG_ENV`).
84+
If no environment is specified, the user will be trusted on the `default` environment.
85+
8386
## Untrusting Users
8487

8588
You can untrust users as well. Please rotate secrets if they are a security concern.
@@ -92,6 +95,11 @@ npx @app-config/cli secret untrust [email protected]
9295
This does not require re-encrypting any secrets. Any new encrypted values will use a
9396
new key that `[email protected]` never had access to.
9497

98+
To specify an encryption environment to untrust the user on, set the standard App-Config environment variables (`ENV`, `NODE_ENV`, or `APP_CONFIG_ENV`).
99+
If no environment is specified, the user will be untrusted on the `default` environment.
100+
101+
To completely untrust a user from your project you must untrust them from all encryption environments they were trusted on.
102+
95103
::: warning
96104
While the above is true, be wary of how the timeline of events interacts with version control.
97105
:::
@@ -107,13 +115,20 @@ This key (public + private) can be added as protected environment variables in y
107115

108116
The CLI will output both of these with instructions.
109117

118+
To use different keys for different secret environments suffix the environment variable names with the name of the environment.
119+
For example - to specify the keys that will be used in an environment called `production` use these environment variables:
120+
121+
- `APP_CONFIG_SECRETS_KEY_PRODUCTION`
122+
- `APP_CONFIG_SECRETS_PUBLIC_KEY_PRODUCTION`
123+
110124
## Implementation Details
111125

112-
- We store a list of team members public keys in meta files
113-
- We store a list of 'encryptionKeys' (symmetric keys) in meta files
126+
- We store a list of team members public keys per encryption environment in meta files
127+
- We store a list of 'encryptionKeys' (symmetric keys) per encryption environment in meta files
114128
- Keys are symmetric, but are themselves stored in encrypted form (encrypted by team members' public keys, which allows any team member to decrypt it)
115129
- Once the key is given to somebody, they can always decrypt secrets that were encrypted with it
116130
- Keys have 'revision' numbers, so we can use the latest one (revision is embedded into the password itself, to prevent tampering in the YAML)
131+
- The encryption environment is included in the revision to determine which symmetric key set to use to decrypt the secret
117132
- By keeping revisions, we can untrust a user without having to re-encrypt every secret made before
118133
- You'd likely still want to rotate most passwords, but doing so automatically (dumping out YAML files everywhere) would be extremely difficult to do right
119134
- The secrets are already compromised, so manual intervention is needed regardless
@@ -146,6 +161,29 @@ It serves no logical roles, it's simply there as metadata for you to identify wh
146161

147162
<h4 style="text-align:center">.app-config.meta.yml</h4>
148163

164+
```yaml
165+
teamMembers:
166+
default:
167+
- userId: Joel Gallant <[email protected]>
168+
keyName: Desktop
169+
publicKey: '...'
170+
- userId: Joel Gallant <[email protected]>
171+
keyName: Laptop
172+
publicKey: '...'
173+
encryptionKeys:
174+
default:
175+
- revision: 1
176+
key: '...'
177+
```
178+
179+
## Multiple Environments
180+
181+
It can be useful to have different levels of trust on the same repository. For example, it may make sense for your project to have fewer people able to decrypt the secrets used on production then the secrets for a QA environment.
182+
183+
To add secret environments to an existing project just move your existing `teamMembers` and `encryptionKeys` values under a `default` property.
184+
185+
For example:
186+
149187
```yaml
150188
teamMembers:
151189
- userId: Joel Gallant <[email protected]>
@@ -158,3 +196,21 @@ encryptionKeys:
158196
- revision: 1
159197
key: '...'
160198
```
199+
200+
Becomes
201+
202+
```yaml
203+
teamMembers:
204+
default:
205+
- userId: Joel Gallant <[email protected]>
206+
keyName: Desktop
207+
publicKey: '...'
208+
- userId: Joel Gallant <[email protected]>
209+
keyName: Laptop
210+
publicKey: '...'
211+
encryptionKeys:
212+
default:
213+
- revision: 1
214+
key: '...'
215+
```
216+
To create a new encryption environment use the `init-key` CLI subcommand while setting one of the standard App-Config environment variables (`ENV`, `NODE_ENV`, or `APP_CONFIG_ENV`) with the new encryption environment.

0 commit comments

Comments
 (0)