3 no if $] >= 5.017011, warnings
=> 'experimental::smartmatch';
6 use Plack
::App
::Gruntmaster
;
11 use constant AUTH_TIMEOUT
=> 5 * 60;
12 use constant ACCESSLOG_FORMAT
=> '%{X-Forwarded-For}i %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i"';
14 sub CONTENT_SECURITY_POLICY
() {
19 frame-ancestors 'none'
20 img-src 'self' https://static.mindcoding.ro https://www.google-analytics.com/collect
21 referrer origin-when-cross-origin
22 script-src https://static.mindcoding.ro/static/js.js https://www.google-analytics.com/analytics.js
23 style-src https://static.mindcoding.ro/static/css/
35 $db //= Gruntmaster
::Data
->connect($ENV{GRUNTMASTER_DSN
} // 'dbi:Pg:');
36 $env->{'gruntmaster.dbic'} = $db;
44 my $resp = $app->($_[0]);
45 my $hdrs = Plack
::Util
::headers
($resp->[1]);
46 $hdrs->set('Content-Security-Policy', CONTENT_SECURITY_POLICY
);
47 $hdrs->set('Cache-Control', 'public, max-age=604800') if $_[0]->{PATH_INFO
} =~ qr
,^/static/,;
48 $resp->[1] = $hdrs->headers;
53 Log
::Log4perl
->init_once('log.conf');
54 my $access_logger = Log
::Log4perl
->get_logger('access');
55 $ENV{DBIC_NULLABLE_KEY_NOWARN
} = 1;
58 enable_if
{ $_[0]->{PATH_INFO
} eq '/ok' } sub { sub{ [200, [], []] }};
59 enable
'AccessLog', format
=> ACCESSLOG_FORMAT
, logger
=> sub { $access_logger->info(@_) };
60 enable
'ContentLength';
62 enable
'Static', path
=> qr
,^/static/,;
63 enable
'Log4perl', category
=> 'plack';
64 enable \
&add_database
;
65 enable
'+Plack::App::Gruntmaster::Auth',
66 dbi_connect
=> [$ENV{GRUNTMASTER_DSN
} // 'dbi:Pg:', '', ''],
67 realm
=> 'Gruntmaster 6000',
68 mail_from
=> $ENV{GRUNTMASTER_RESET_FROM
};
69 Plack
::App
::Gruntmaster
->run_if_script