From 1d2cbe7de84c2a13df953866f1fcadfe1b140283 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Mon, 10 Feb 2014 13:05:59 +0200 Subject: [PATCH] Add Content-Security-Policy --- app.psgi | 2 ++ 1 file changed, 2 insertions(+) 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'; -- 2.39.2