]> iEval git - plack-app-gruntmaster.git/commitdiff
Add Content-Security-Policy
authorMarius Gavrilescu <marius@ieval.ro>
Mon, 10 Feb 2014 11:05:59 +0000 (13:05 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Mon, 10 Feb 2014 11:05:59 +0000 (13:05 +0200)
app.psgi

index 56022bc727880ff490ff33545981890d1c635c50..9908172efb807320b8562f03bc201b43a6048c40 100644 (file)
--- 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';
This page took 0.018387 seconds and 4 git commands to generate.