History

Add KMS master key from Docker secret (#7825)

Lucas committed 7 years ago

Commit ea66a521 parent 55dd0175 files · +40 −4Browse files

Unified · Split

5 files
  1. Dockerfile +2 −1
  2. Dockerfile.dev +2 −1
  3. Dockerfile.release +2 −1
  4. dockerscripts/docker-entrypoint.sh +14 −0
  5. docs/kms/README.md +20 −1
Dockerfile+2−1
@@ -16,7 +16,8 @@ FROM alpine:3.9 · 15 unmodified lines
1616
1717 ENV MINIO_UPDATE off
1818 ENV MINIO_ACCESS_KEY_FILE=access_key \
19− MINIO_SECRET_KEY_FILE=secret_key
19+ MINIO_SECRET_KEY_FILE=secret_key \
20+ MINIO_SSE_MASTER_KEY_FILE=sse_master_key
2021
2122 EXPOSE 9000
2223
Dockerfile.dev+2−1
@@ -7,7 +7,8 @@ COPY minio /usr/bin/ · 6 unmodified lines
77
88 ENV MINIO_UPDATE off
99 ENV MINIO_ACCESS_KEY_FILE=access_key \
10− MINIO_SECRET_KEY_FILE=secret_key
10+ MINIO_SECRET_KEY_FILE=secret_key \
11+ MINIO_SSE_MASTER_KEY_FILE=sse_master_key
1112
1213 RUN \
1314 apk add --no-cache ca-certificates 'curl>7.61.0' 'su-exec>=0.2' && \
Dockerfile.release+2−1
@@ -18,7 +18,8 @@ COPY dockerscripts/docker-entrypoint.sh /usr/bin/ · 17 unmodified lines
1818
1919 ENV MINIO_UPDATE off
2020 ENV MINIO_ACCESS_KEY_FILE=access_key \
21− MINIO_SECRET_KEY_FILE=secret_key
21+ MINIO_SECRET_KEY_FILE=secret_key \
22+ MINIO_SSE_MASTER_KEY_FILE=sse_master_key
2223
2324 RUN \
2425 apk add --no-cache ca-certificates 'curl>7.61.0' 'su-exec>=0.2' && \
dockerscripts/docker-entrypoint.sh+14−0
@@ -39,6 +39,17 @@ docker_secrets_env() { · 38 unmodified lines
3939 fi
4040 }
4141
42+## Set SSE_MASTER_KEY from docker secrets if provided
43+docker_sse_encryption_env() {
44+ SSE_MASTER_KEY_FILE="/run/secrets/$MINIO_SSE_MASTER_KEY_FILE"
45+
46+ if [ -f "$SSE_MASTER_KEY_FILE" ]; then
47+ MINIO_SSE_MASTER_KEY="$(cat "$SSE_MASTER_KEY_FILE")"
48+ export MINIO_SSE_MASTER_KEY
49+
50+ fi
51+}
52+
4253 # su-exec to requested user, if service cannot run exec will fail.
4354 docker_switch_user() {
4455 if [ -z "${MINIO_USERNAME}" ] || [ -z "${MINIO_GROUPNAME}" ]; then
@@ -55,5 +66,8 @@ docker_switch_user() { · 10 unmodified lines
5566 ## Set access env from secrets if necessary.
5667 docker_secrets_env
5768
69+## Set sse encryption from secrets if necessary.
70+docker_sse_encryption_env
71+
5872 ## Switch to user if applicable.
5973 docker_switch_user "$@"
docs/kms/README.md+20−1
@@ -12,7 +12,7 @@ MinIO supports two different KMS concepts: · 11 unmodified lines
1212 by enabling or disabling the corresponding master keys on demand.
1313
1414 - Direct KMS master keys:
15− MinIO can also be configured to directly use a master key specified by the environment variable `MINIO_SSE_MASTER_KEY`.
15+ MinIO can also be configured to directly use a master key specified by the environment variable `MINIO_SSE_MASTER_KEY` or with a docker secret key.
1616 Direct master keys are useful if the storage backend is not on the same machine as the MinIO server, e.g.,
1717 if network drives or MinIO gateway is used and an external KMS would cause too much management overhead.
1818
@@ -215,6 +215,8 @@ minio gateway s3 · 196 unmodified lines
215215
216216 #### 2.2 Specify a master key
217217
218+**2.2.1 KMS master key from environment variables**
219+
218220 A KMS master key consists of a master-key ID (CMK) and the 256 bit master key encoded as HEX value separated by a `:`.
219221 A KMS master key can be specified directly using:
220222
@@ -228,6 +230,23 @@ Please use your own master key. A random master key can be generated using e.g. · 7 unmodified lines
228230 head -c 32 /dev/urandom | xxd -c 32 -ps
229231 ```
230232
233+**2.2.2 KMS master key from docker secret**
234+
235+Alternatively, you may pass a master key as a [Docker secret](https://docs.docker.com/engine/swarm/secrets/).
236+
237+```bash
238+echo "my-minio-key:6368616e676520746869732070617373776f726420746f206120736563726574" | docker secret create sse_master_key
239+```
240+
241+Obviously, do not use this demo key for anything real!
242+
243+To use another secret name, follow the instructions above and replace sse_master_key with your custom names (e.g. my_sse_master_key).
244+Then, set the MINIO_SSE_MASTER_KEY_FILE environment variable to your secret name:
245+
246+```bash
247+export MINIO_SSE_MASTER_KEY_FILE=my_sse_master_key
248+```
249+
231250 ### 3. Test your setup
232251 To test this setup, start minio server with environment variables set in Step 3, and server is ready to handle SSE-S3 requests.
233252

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t