From 207dadd5cc84455cb9c7d05d3c07af8088f2a69c Mon Sep 17 00:00:00 2001 From: Benjamin Bohard Date: Thu, 12 Dec 2019 12:01:00 +0100 Subject: [PATCH] Add variables to defined allowed CSP targets --- dicos/70_lemonldap_ng.xml | 2 ++ tmpl/portal-nginx.conf | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dicos/70_lemonldap_ng.xml b/dicos/70_lemonldap_ng.xml index bfede2a..797333b 100644 --- a/dicos/70_lemonldap_ng.xml +++ b/dicos/70_lemonldap_ng.xml @@ -67,6 +67,7 @@ + Configuration DNS @@ -132,5 +133,6 @@ DN de l'utilisateur de connection en lecture à l'annuaire (ex: cn=reader,o=gouv,c=fr) server_names_hash_bucket_size Taille du hash des noms de serveur pour NGINX Affiche une case à cocher sur la mire SSO qui permet a l'utilisateur de voir l'historique de connection de son compte avant d'être redirigé vers le service demandé + Liste des domaines à ajouter à la directive form-action. diff --git a/tmpl/portal-nginx.conf b/tmpl/portal-nginx.conf index c753c04..701f484 100644 --- a/tmpl/portal-nginx.conf +++ b/tmpl/portal-nginx.conf @@ -5,6 +5,8 @@ # ~/CN=(?[^/]+) $CN; #} %set %%webDomain = %%authWebName.split('.',1)[1] +%set %%CSPTargets = %%custom_join(['http://*.{0} https://*.{0}'.format(d) for d in set([%%webDomain] + %%getVar('llCSPTargets'))], ' ') + server { listen 80; @@ -42,7 +44,7 @@ server { fastcgi_split_path_info ^(.*\.psgi)(/.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_hide_header Content-Security-Policy; - add_header Content-Security-Policy "default-src 'self'; form-action 'self' http://*.%%webDomain https://*.%%webDomain; object-src 'none'"; + add_header Content-Security-Policy "default-src 'self'; form-action 'self' %%CSPTargets; object-src 'none'"; }