mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-05-14 01:04:55 +02:00
Added CSP exceptions for presentation and portfolio
This commit is contained in:
parent
3cb4cbf0d2
commit
13e98beed2
@ -1,4 +1,15 @@
|
||||
features:
|
||||
matomo: true
|
||||
css: true
|
||||
landingpage_iframe: false
|
||||
landingpage_iframe: false
|
||||
csp:
|
||||
whitelist:
|
||||
script-src:
|
||||
- https://cdn.jsdelivr.net
|
||||
- https://kit.fontawesome.com
|
||||
style-src:
|
||||
- https://cdn.jsdelivr.net
|
||||
font-src:
|
||||
- https://ka-f.fontawesome.com
|
||||
frame-src:
|
||||
- "{{ web_protocol }}://*.{{primary_domain}}"
|
||||
|
@ -1,4 +1,16 @@
|
||||
features:
|
||||
matomo: true
|
||||
css: true
|
||||
landingpage_iframe: true
|
||||
landingpage_iframe: true
|
||||
|
||||
csp:
|
||||
whitelist:
|
||||
script-src:
|
||||
- https://cdnjs.cloudflare.com
|
||||
- https://code.jquery.com
|
||||
- https://cdn.jsdelivr.net
|
||||
style-src:
|
||||
- https://cdnjs.cloudflare.com
|
||||
- https://cdn.jsdelivr.net
|
||||
font-src:
|
||||
- https://cdnjs.cloudflare.com
|
@ -12,7 +12,7 @@
|
||||
'font-src'
|
||||
] %}
|
||||
|
||||
{# Loop over each directive and build its value from 'self', any unsafe flags, and whitelisted URLs #}
|
||||
{# Loop over each directive and build its value from 'self', any unsafe flags, whitelist URLs, and optional Matomo #}
|
||||
{%- for directive in directives %}
|
||||
{# Start with the 'self' source #}
|
||||
{%- set tokens = ["'self'"] %}
|
||||
@ -22,19 +22,24 @@
|
||||
{%- set tokens = tokens + [flag] %}
|
||||
{%- endfor %}
|
||||
|
||||
{# If Matomo feature is enabled, whitelist its script and connect sources #}
|
||||
{%- if applications | is_feature_enabled('matomo', application_id) and directive in ['script-src','connect-src'] %}
|
||||
{%- set tokens = tokens + ['{{ web_protocol }}://{{ domains.matomo }}'] %}
|
||||
{%- endif %}
|
||||
|
||||
{# Add any extra hosts/URLs from csp.whitelist.<directive> #}
|
||||
{%- for url in applications | get_csp_whitelist(application_id, directive) %}
|
||||
{%- set tokens = tokens + [url] %}
|
||||
{%- endfor %}
|
||||
|
||||
{# Combine into a single directive line and append to csp_parts #}
|
||||
{%- set csp_parts = csp_parts + [(directive ~ " " ~ (tokens | join(' ')) ~ ";")] %}
|
||||
{%- set csp_parts = csp_parts + [directive ~ ' ' ~ (tokens | join(' ')) ~ ';'] %}
|
||||
{%- endfor %}
|
||||
|
||||
{# Preserve original img-src directive logic (do not loop) #}
|
||||
{%- set img_src = "img-src * data: blob:" %}
|
||||
{%- set csp_parts = csp_parts + [img_src ~ ";"] %}
|
||||
{%- set img_src = 'img-src * data: blob:' %}
|
||||
{%- set csp_parts = csp_parts + [img_src ~ ';'] %}
|
||||
|
||||
{# Emit the assembled Content-Security-Policy header and hide any upstream CSP header #}
|
||||
add_header Content-Security-Policy "{{ csp_parts | join(' ') }}" always;
|
||||
proxy_hide_header Content-Security-Policy;
|
||||
proxy_hide_header Content-Security-Policy;
|
||||
|
Loading…
x
Reference in New Issue
Block a user