Skip to content

Commit

Permalink
Merge pull request #2396 from betagouv/fix/cms_s3_content_policy
Browse files Browse the repository at this point in the history
fix: add CSP with a ROOT trusted domain
  • Loading branch information
nmrgt authored Feb 1, 2024
2 parents 5d80249 + 0df508f commit a02e726
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
24 changes: 22 additions & 2 deletions cms/config/middlewares.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
export default [
'strapi::logger',
'strapi::errors',
'strapi::security',
{
name: 'strapi::security',
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
'img-src': [
"'self'",
"data:",
"blob:",
`*.${process.env.TRUSTED_ROOT_DOMAIN}`,
],
'media-src': [
"'self'",
"data:",
"blob:",
`*.${process.env.TRUSTED_ROOT_DOMAIN}`,
],
},
},
},
},
'strapi::cors',
'strapi::poweredBy',
'strapi::query',
'strapi::body',
'strapi::session',
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ services:
S3_ENDPOINT: http://s3:9000
S3_REGION: fr-par
S3_BUCKET: cms
S3_PUBLIC_URL: https://cms.s3.covoiturage.test
TRUSTED_ROOT_DOMAIN: covoiturage.test
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.api.rule=Host(`cms.covoiturage.test`)'
Expand Down Expand Up @@ -221,7 +223,7 @@ services:
MINIO_DOMAIN: s3.covoiturage.test
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.s3.rule=Host(`s3.covoiturage.test`, `local-pdc-export.s3.covoiturage.test`, `download.covoiturage.test`)'
- 'traefik.http.routers.s3.rule=Host(`s3.covoiturage.test`, `local-pdc-export.s3.covoiturage.test`, `download.covoiturage.test`, `cms.s3.covoiturage.test`)'
- 'traefik.http.routers.s3.entrypoints=websecure'
- 'traefik.http.routers.s3.tls=true'
- 'traefik.http.services.s3.loadbalancer.server.port=9000'
Expand Down

0 comments on commit a02e726

Please sign in to comment.