use constant AUTH_TIMEOUT => 5 * 60;
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'; frame-src free.timeanddate.com,;
+use constant CONTENT_SECURITY_POLICY => q,default-src 'none'; script-src 'self' www.google-analytics.com; style-src 'self'; img-src 'self' www.google-analytics.com; connect-src 'self',;
-my $db = Gruntmaster::Data->connect('dbi:Pg:');
+our $db //= Gruntmaster::Data->connect($ENV{GRUNTMASTER_DSN} // 'dbi:Pg:');
-tie my %auth, 'Tie::Hash::Expire', {expire_seconds => 300};
+tie my %auth, 'Tie::Hash::Expire', {expire_seconds => AUTH_TIMEOUT};
sub authenticate {
my ($user, $pass, $env) = @_;
}
}
-Log::Log4perl->init('log.conf');
+Log::Log4perl->init_once('log.conf');
my $access_logger = Log::Log4perl->get_logger('access');
$ENV{DBIC_NULLABLE_KEY_NOWARN} = 1;
builder {
+ enable_if { $_[0]->{PATH_INFO} eq '/ok' } sub { sub{ [200, [], []] }};
enable 'AccessLog', format => ACCESSLOG_FORMAT, logger => sub { $access_logger->info(@_) };
enable 'ContentLength';
enable \&add_headers;
enable 'Static', path => qr,^/static/,;
enable 'Log4perl', category => 'plack';
enable_if { shift->{HTTP_AUTHORIZATION} } 'Auth::Basic', authenticator => \&authenticate, realm => 'Gruntmaster 6000';
- enable_if { $_[0]->{PATH_INFO} eq '/ok' } sub { sub{ [200, [], []] }};
enable sub { my $app = $_[0]; sub { $_[0]->{'gruntmaster.dbic'} = $db; $app->($_[0]) } };
Plack::App::Gruntmaster->run_if_script
}