Skip to content

Commit 2f48df9

Browse files
committed
feat: replace single key by a jwks in docker-compose
1 parent 415f953 commit 2f48df9

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

tests/CI/docker-compose.yml

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ services:
4848
volumes:
4949
- diracx-iam-key-store:/etc/indigo-iam/keystore
5050
depends_on:
51-
- iam-init-jwks
51+
- iam-init-keystore
5252
healthcheck:
5353
test: ["CMD", "curl", "-f", "http://localhost:8080/.well-known/openid-configuration"]
5454
interval: 5s
@@ -57,9 +57,9 @@ services:
5757
start_period: 60s
5858
pull_policy: always
5959

60-
iam-init-jwks:
60+
iam-init-keystore:
6161
image: alpine:latest
62-
container_name: init-jwks
62+
container_name: iam-init-keystore
6363
volumes:
6464
- diracx-iam-key-store:/jwks
6565
command: >
@@ -130,7 +130,7 @@ services:
130130
condition: service_healthy
131131
dirac-init-certificates:
132132
condition: service_completed_successfully # Let the init container create the certificates
133-
diracx-init-key:
133+
diracx-init-keystore:
134134
condition: service_completed_successfully # Let the init container create the signing key
135135
diracx-init-cs:
136136
condition: service_completed_successfully # Let the init container create the cs
@@ -139,10 +139,10 @@ services:
139139
volumes:
140140
- certs_data:/ca/certs
141141
- diracx-cs-store:/cs_store
142-
- diracx-key-store:/signing-key
142+
- diracx-key-store:/keystore
143143
environment:
144144
- DIRACX_CONFIG_BACKEND_URL=git+file:///cs_store/initialRepo
145-
- DIRACX_SERVICE_AUTH_TOKEN_KEY=file:///signing-key/rs256.key
145+
- DIRACX_SERVICE_AUTH_TOKEN_KEYSTORE=file:///keystore/jwks.json
146146
command: ["sleep", "infinity"] # This is necessary because of the issue described in https://github.com/moby/moby/issues/42275. What is added here is a hack/workaround.
147147
pull_policy: always
148148

@@ -185,33 +185,49 @@ services:
185185
start_period: 60s
186186
command: ["sleep", "infinity"] # This is necessary because of the issue described in https://github.com/moby/moby/issues/42275. What is added here is a hack/workaround.
187187

188-
diracx-init-key:
188+
189+
diracx-chmod:
189190
image: ghcr.io/diracgrid/diracx/secret-generation:latest
190-
container_name: diracx-init-key
191-
environment:
192-
- DIRACX_SERVICE_AUTH_TOKEN_KEY="file:///signing-key/rs256.key"
191+
container_name: diracx-chmod
193192
volumes:
194-
- diracx-key-store:/signing-key/
195-
# As the diracx images don't run as root we need to change the permissions of the /cs_store/ directory as well
193+
# As the diracx images don't run as root we need to change the permissions of the directories as well
194+
- diracx-key-store:/keystore/
196195
- diracx-cs-store:/cs_store/
197196
# We need to allow everybody to read the private keys
198197
# Because the users are different between the DIRAC and DiracX containers
199198
entrypoint: |
200-
bash -xc "ssh-keygen -P '' -trsa -b4096 -mPEM -f/signing-key/rs256.key && chmod o+r /signing-key/rs256.* && chmod -R o=u /cs_store"
199+
bash -xc 'chmod -R o=u /keystore && chmod -R o=u /cs_store'
200+
pull_policy: always
201+
202+
203+
diracx-init-keystore:
204+
image: ghcr.io/diracgrid/diracx/services:dev
205+
container_name: diracx-init-keystore
206+
depends_on:
207+
diracx-chmod:
208+
condition: service_completed_successfully # Let the init container set the permission on /keystore/
209+
environment:
210+
- DIRACX_SERVICE_AUTH_TOKEN_KEYSTORE="file:///keystore/jwks.json"
211+
volumes:
212+
- diracx-key-store:/keystore/
213+
entrypoint: |
214+
/entrypoint.sh bash -xc 'python -m diracx.logic rotate-jwk --jwks-path /keystore/jwks.json'
201215
pull_policy: always
202216

203217
diracx-init-cs:
204218
image: ghcr.io/diracgrid/diracx/client:dev
205219
container_name: diracx-init-cs
206220
depends_on:
207-
diracx-init-key:
221+
diracx-chmod:
208222
condition: service_completed_successfully # Let the init container set the permission on /cs_store/
223+
diracx-init-keystore:
224+
condition: service_completed_successfully # Let the init container create the signing key
209225
environment:
210226
- DIRACX_CONFIG_BACKEND_URL=git+file:///cs_store/initialRepo
211-
- DIRACX_SERVICE_AUTH_TOKEN_KEY=file:///signing-key/rs256.key
227+
- DIRACX_SERVICE_AUTH_TOKEN_KEYSTORE=file:///keystore/jwks.json
212228
volumes:
213229
- diracx-cs-store:/cs_store/
214-
- diracx-key-store:/signing-key/
230+
- diracx-key-store:/keystore/
215231
entrypoint: |
216232
/entrypoint.sh bash -xc 'dirac internal generate-cs /cs_store/initialRepo'
217233
pull_policy: always
@@ -239,7 +255,7 @@ services:
239255
- DIRACX_DB_URL_SANDBOXMETADATADB=mysql+aiomysql://Dirac:Dirac@mysql/SandboxMetadataDB
240256
- DIRACX_DB_URL_PILOTAGENTSDB=mysql+aiomysql://Dirac:Dirac@mysql/PilotAgentsDB
241257
- 'DIRACX_OS_DB_PILOTLOGSDB={"sqlalchemy_dsn": "mysql+aiomysql://Dirac:Dirac@mysql/PilotLogsDB"}'
242-
- DIRACX_SERVICE_AUTH_TOKEN_KEY=file:///signing-key/rs256.key
258+
- DIRACX_SERVICE_AUTH_TOKEN_KEYSTORE=file:///keystore/jwks.json
243259
- DIRACX_SERVICE_AUTH_TOKEN_ISSUER=http://diracx:8000
244260
- DIRACX_SERVICE_AUTH_ALLOWED_REDIRECTS=["http://diracx:8000/docs/oauth2-redirect"]
245261
# Obtained with head -c 32 /dev/urandom | base64
@@ -256,7 +272,7 @@ services:
256272
condition: service_completed_successfully
257273
volumes:
258274
- diracx-cs-store:/cs_store/
259-
- diracx-key-store:/signing-key/
275+
- diracx-key-store:/keystore/
260276
entrypoint: |
261277
/entrypoint.sh bash -xc 'uvicorn --factory diracx.routers:create_app --host=0.0.0.0'
262278

0 commit comments

Comments
 (0)