Koozali.org: home of the SME Server
Contribs.org Forums => Development => Topic started by: frifri on June 08, 2016, 12:40:23 PM
-
Hi all,
I want to make a httpd.conf-template for enabling 'Content Security Policy' on VirtualHosts.
info :
http://content-security-policy.com/
https://securityheaders.io
This is what i tried, but it doesn't work :
{
use esmith::AccountsDB;
my $accounts = esmith::AccountsDB->open_ro;
my $CSP = $accounts->get_prop($ibay, "CSP") || "";
if ($CSP ne '')
{
$OUT .= " Header set Content-Security-Policy \"$CSP\"\n";
}
}
-
This is what i tried, but it doesn't work
Doesn't work is a bit too vague. Please give us some details (where did you wirte this custom templates, and what isn't working as expected)
-
Hi Daniël,
I get a lot of these :
WARNING in /etc/e-smith/templates//etc/httpd/conf/httpd.conf/80VirtualHosts: Use of uninitialized value in concatenation (.) or string at /etc/e-smith/templates //etc/httpd/conf/httpd.conf/80VirtualHosts line 38.
WARNING in /etc/e-smith/templates-custom//etc/httpd/conf/httpd.conf/VirtualHosts/06CSP: Use of uninitialized value $Text::Template::ERROR in concatenation (.) or string at /usr/share/perl5/vendor_perl/esmith/templates.pm line 579.
WARNING in /etc/e-smith/templates-custom//etc/httpd/conf/httpd.conf/VirtualHosts/06CSP: ERROR: Cannot process template /etc/e-smith/templates-custom//etc/httpd/conf/httpd.conf/VirtualHosts/06CSP: at /etc/e-smith/templates//etc/httpd/conf/httpd.conf/80VirtualHosts line 38
F.
-
$ibays is not defined globaly. Try replacing it with $virtualHostContent
-
Thanks Daniël !
This custom-template does what i need :
{
use esmith::AccountsDB;
my $accounts = esmith::AccountsDB->open_ro;
my $ibay = $virtualHostContent;
my $CSP = $accounts->get_prop($ibay, "CSP") || "";
if ($CSP ne '')
{
$OUT .= " # Content-Security-Policy\n";
$OUT .= " Header set Content-Security-Policy \"$CSP\"\n";
}
}
F.
-
could it be of common use to add this option as the regular template ?
if so we could open a NFR against SME10 and maybe backport it to SME9
-
I agree, please do, TIA
-
It could, but it needs more documentation.
Server-Manager needs at least CSP="default-src 'self'; script-src 'unsafe-inline'; style-src 'self' 'unsafe-inline';" ...
F.
-
please, open a NFR, attach you code and add all your observations, thank you