Skip to content

Commit e30294e

Browse files
committed
Allow specifying additional custom CSP directives
1 parent eaf927a commit e30294e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

schemas/qwc-map-viewer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@
143143
"type": "array",
144144
"items": {
145145
"type": "string"
146+
},
147+
"extra_csp_directives": {
148+
"description": "Extra Content-Security-Policy header directives",
149+
"type": "string"
146150
}
147151
}
148152
},

src/qwc2_viewer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def __init__(self, tenant, tenant_handler, logger):
108108

109109
self.user_info_fields = config.get('user_info_fields', [])
110110
self.display_user_info_field = config.get('display_user_info_field')
111+
self.extra_csp_directives = config.get('extra_csp_directives')
111112

112113
# get config dir for tenant
113114
self.config_dir = os.path.dirname(
@@ -213,6 +214,8 @@ def qwc2_index(self, identity, params, request_url):
213214
"script-src 'nonce-%s' 'strict-dynamic'" % nonce,
214215
# "style-src 'nonce-%s'" % nonce # TODO
215216
])
217+
if self.extra_csp_directives:
218+
csp += "; " + self.extra_csp_directives
216219
viewer_index = viewer_index.replace('<head>', '<head>\n<meta http-equiv="Content-Security-Policy" content="%s">' % csp)
217220
viewer_index = viewer_index.replace('<script ', '<script nonce="%s" ' % nonce)
218221

0 commit comments

Comments
 (0)