@@ -42,26 +42,26 @@ Additional database fields may be encrypted in the future.
42
42
43
43
## Enabling encryption
44
44
45
- 1 . Ensure you have a valid backup of your database. ** Do not skip this step.**
46
- If you are using the built-in PostgreSQL database, you can run
47
- [ ` coder server postgres-builtin-url ` ] ( ../cli/server_postgres-builtin-url.md )
48
- to get the connection URL.
45
+ - Ensure you have a valid backup of your database. ** Do not skip this step.** If
46
+ you are using the built-in PostgreSQL database, you can run
47
+ [ ` coder server postgres-builtin-url ` ] ( ../cli/server_postgres-builtin-url.md )
48
+ to get the connection URL.
49
49
50
- 1 . Generate a 32-byte random key and base64-encode it. For example:
50
+ - Generate a 32-byte random key and base64-encode it. For example:
51
51
52
52
``` shell
53
53
dd if=/dev/urandom bs=32 count=1 | base64
54
54
```
55
55
56
- 1 . Store this key in a secure location (for example, a Kubernetes secret):
56
+ - Store this key in a secure location (for example, a Kubernetes secret):
57
57
58
58
``` shell
59
59
kubectl create secret generic coder-external-token-encryption-keys --from-literal=keys=< key>
60
60
```
61
61
62
- 1 . In your Coder configuration set ` CODER_EXTERNAL_TOKEN_ENCRYPTION_KEYS ` to a
63
- comma-separated list of base64-encoded keys. For example, in your Helm
64
- ` values.yaml ` :
62
+ - In your Coder configuration set ` CODER_EXTERNAL_TOKEN_ENCRYPTION_KEYS ` to a
63
+ comma-separated list of base64-encoded keys. For example, in your Helm
64
+ ` values.yaml ` :
65
65
66
66
``` yaml
67
67
coder :
@@ -74,22 +74,22 @@ coder:
74
74
key : keys
75
75
` ` `
76
76
77
- 1. Restart the Coder server. The server will now encrypt all new data with the
78
- provided key.
77
+ - Restart the Coder server. The server will now encrypt all new data with the
78
+ provided key.
79
79
80
80
## Rotating keys
81
81
82
82
We recommend only having one active encryption key at a time normally. However,
83
83
if you need to rotate keys, you can perform the following procedure:
84
84
85
- 1. Ensure you have a valid backup of your database. **Do not skip this step.**
85
+ - Ensure you have a valid backup of your database. **Do not skip this step.**
86
86
87
- 1. Generate a new encryption key following the same procedure as above.
87
+ - Generate a new encryption key following the same procedure as above.
88
88
89
- 1. Add the above key to the list of
90
- [external token encryption keys](../cli/server.md#--external-token-encryption-keys).
91
- **The new key must appear first in the list**. For example, in the Kubernetes
92
- secret created above:
89
+ - Add the above key to the list of
90
+ [external token encryption keys](../cli/server.md#--external-token-encryption-keys).
91
+ **The new key must appear first in the list**. For example, in the Kubernetes
92
+ secret created above:
93
93
94
94
` ` ` yaml
95
95
apiVersion : v1
@@ -102,70 +102,70 @@ data:
102
102
keys : <new-key>,<old-key1>,<old-key2>,...
103
103
` ` `
104
104
105
- 1. After updating the configuration, restart the Coder server. The server will
106
- now encrypt all new data with the new key, but will be able to decrypt tokens
107
- encrypted with the old key(s).
105
+ - After updating the configuration, restart the Coder server. The server will
106
+ now encrypt all new data with the new key, but will be able to decrypt tokens
107
+ encrypted with the old key(s).
108
108
109
- 1. To re-encrypt all encrypted database fields with the new key, run
110
- [` coder server dbcrypt rotate`](../cli/server_dbcrypt_rotate.md). This
111
- command will re-encrypt all tokens with the specified new encryption key. We
112
- recommend performing this action during a maintenance window.
109
+ - To re-encrypt all encrypted database fields with the new key, run
110
+ [` coder server dbcrypt rotate`](../cli/server_dbcrypt_rotate.md). This command
111
+ will re-encrypt all tokens with the specified new encryption key. We recommend
112
+ performing this action during a maintenance window.
113
113
114
- > Note: this command requires direct access to the database. If you are using
115
- > the built-in PostgreSQL database, you can run
116
- > [`coder server postgres-builtin-url`](../cli/server_postgres-builtin-url.md)
117
- > to get the connection URL.
114
+ > Note: this command requires direct access to the database. If you are using
115
+ > the built-in PostgreSQL database, you can run
116
+ > [`coder server postgres-builtin-url`](../cli/server_postgres-builtin-url.md)
117
+ > to get the connection URL.
118
118
119
- 1. Once the above command completes successfully, remove the old encryption key
120
- from Coder's configuration and restart Coder once more. You can now safely
121
- delete the old key from your secret store.
119
+ - Once the above command completes successfully, remove the old encryption key
120
+ from Coder's configuration and restart Coder once more. You can now safely
121
+ delete the old key from your secret store.
122
122
123
123
# # Disabling encryption
124
124
125
125
To disable encryption, perform the following actions :
126
126
127
- 1. Ensure you have a valid backup of your database. **Do not skip this step.**
127
+ - Ensure you have a valid backup of your database. **Do not skip this step.**
128
128
129
- 1. Stop all active coderd instances. This will prevent new encrypted data from
130
- being written, which may cause the next step to fail.
129
+ - Stop all active coderd instances. This will prevent new encrypted data from
130
+ being written, which may cause the next step to fail.
131
131
132
- 1. Run [`coder server dbcrypt decrypt`](../cli/server_dbcrypt_decrypt.md). This
133
- command will decrypt all encrypted user tokens and revoke all active
134
- encryption keys.
132
+ - Run [`coder server dbcrypt decrypt`](../cli/server_dbcrypt_decrypt.md). This
133
+ command will decrypt all encrypted user tokens and revoke all active
134
+ encryption keys.
135
135
136
- > Note: for `decrypt` command, the equivalent environment variable for
137
- > `--keys` is `CODER_EXTERNAL_TOKEN_ENCRYPTION_DECRYPT_KEYS` and not
138
- > `CODER_EXTERNAL_TOKEN_ENCRYPTION_KEYS`. This is explicitly named
139
- > differently to help prevent accidentally decrypting data.
136
+ > Note: for `decrypt` command, the equivalent environment variable for
137
+ > `--keys` is `CODER_EXTERNAL_TOKEN_ENCRYPTION_DECRYPT_KEYS` and not
138
+ > `CODER_EXTERNAL_TOKEN_ENCRYPTION_KEYS`. This is explicitly named differently
139
+ > to help prevent accidentally decrypting data.
140
140
141
- 1. Remove all
142
- [external token encryption keys](../cli/server.md#--external-token-encryption-keys)
143
- from Coder's configuration.
141
+ - Remove all
142
+ [external token encryption keys](../cli/server.md#--external-token-encryption-keys)
143
+ from Coder's configuration.
144
144
145
- 1. Start coderd. You can now safely delete the encryption keys from your secret
146
- store.
145
+ - Start coderd. You can now safely delete the encryption keys from your secret
146
+ store.
147
147
148
148
# # Deleting Encrypted Data
149
149
150
150
> NOTE: This is a destructive operation.
151
151
152
152
To delete all encrypted data from your database, perform the following actions :
153
153
154
- 1. Ensure you have a valid backup of your database. **Do not skip this step.**
154
+ - Ensure you have a valid backup of your database. **Do not skip this step.**
155
155
156
- 1. Stop all active coderd instances. This will prevent new encrypted data from
157
- being written.
156
+ - Stop all active coderd instances. This will prevent new encrypted data from
157
+ being written.
158
158
159
- 1. Run [`coder server dbcrypt delete`](../cli/server_dbcrypt_delete.md). This
160
- command will delete all encrypted user tokens and revoke all active
161
- encryption keys.
159
+ - Run [`coder server dbcrypt delete`](../cli/server_dbcrypt_delete.md). This
160
+ command will delete all encrypted user tokens and revoke all active encryption
161
+ keys.
162
162
163
- 1. Remove all
164
- [external token encryption keys](../cli/server.md#--external-token-encryption-keys)
165
- from Coder's configuration.
163
+ - Remove all
164
+ [external token encryption keys](../cli/server.md#--external-token-encryption-keys)
165
+ from Coder's configuration.
166
166
167
- 1. Start coderd. You can now safely delete the encryption keys from your secret
168
- store.
167
+ - Start coderd. You can now safely delete the encryption keys from your secret
168
+ store.
169
169
170
170
# # Troubleshooting
171
171
0 commit comments