From: Marius Gavrilescu Date: Mon, 10 Feb 2014 11:05:59 +0000 (+0200) Subject: Add Content-Security-Policy X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=1d2cbe7de84c2a13df953866f1fcadfe1b140283;p=plack-app-gruntmaster.git Add Content-Security-Policy --- diff --git a/app.psgi b/app.psgi index 56022bc..9908172 100644 --- a/app.psgi +++ b/app.psgi @@ -11,6 +11,7 @@ use Digest::SHA qw/sha256/; use Log::Log4perl; use constant ACCESSLOG_FORMAT => '%{X-Forwarded-For}i|%h %u "%r" %>s %b "%{Referer}i" "%{User-agent}i"'; +use constant CONTENT_SECURITY_POLICY => q,default-src 'none'; script-src 'self' www.google-analytics.com; style-src 'self'; img-src 'self'; connect-src 'self',; $Apache2::AuthzCaps::rootdir = $Apache2::Authen::Passphrase::rootdir; my $word = qr,(\w+),a; @@ -75,6 +76,7 @@ builder { enable_if { $_[0]->{PATH_INFO} eq '/ok' } sub { sub{ [200, [], []] }}; enable 'AccessLog', format => ACCESSLOG_FORMAT, logger => sub { $access_logger->info(@_) }; enable 'ContentLength'; + enable Header => set => ['Content-Security-Policy', CONTENT_SECURITY_POLICY]; enable_if { $_[0]->{PATH_INFO} =~ qr,^/static/,} Header => set => ['Cache-Control', 'public, max-age=604800']; enable 'Static', path => qr,^/static/,; enable 'Log4perl', category => 'plack';