Skip to content

Commit

Permalink
Configuring Content Security Policy
Browse files Browse the repository at this point in the history
  • Loading branch information
guilbaults committed Jul 18, 2024
1 parent f6c9e83 commit 7aefd88
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions userportal/settings/10-base.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
"""
Django settings for userportal project.
Generated by 'django-admin startproject' using Django 3.1.7.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

from pathlib import Path
Expand Down Expand Up @@ -43,6 +35,7 @@
'django.contrib.staticfiles',
'django.contrib.humanize',
'djangosaml2',
'csp',
'watchman',

'pages',
Expand Down Expand Up @@ -78,6 +71,7 @@
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'djangosaml2.middleware.SamlSessionMiddleware',
'csp.middleware.CSPMiddleware',
]

ROOT_URLCONF = 'userportal.urls'
Expand Down Expand Up @@ -204,3 +198,9 @@
'DEFAULT_PAGINATION_CLASS': 'rest_framework_datatables.pagination.DatatablesPageNumberPagination',
'PAGE_SIZE': 100,
}

# Content Security Policy
CSP_DEFAULT_SRC = ("'self'")
CSP_IMG_SRC = ("'self'", "data:", 'object-arbutus.cloud.computecanada.ca')
CSP_STYLE_SRC = ("'self'", "'unsafe-inline'", 'cdn.jsdelivr.net', 'cdnjs.cloudflare.com', 'cdn.datatables.net')
CSP_SCRIPT_SRC = ("'self'", "'unsafe-inline'", 'cdn.jsdelivr.net', 'cdnjs.cloudflare.com', 'cdn.datatables.net', 'code.jquery.com', 'cdn.plot.ly')

0 comments on commit 7aefd88

Please sign in to comment.