]>
iEval git - gruntmaster-page.git/blob - app.psgi
b1bd530dffa5fb4db7bb074a0005b5bb8a757921
4 use Apache2
::Authen
::Passphrase qw
/pwcheck/;
5 use Apache2
::AuthzCaps qw
/hascaps/;
7 use Plack
::App
::Gruntmaster
;
10 use Digest
::SHA qw
/sha256/;
12 $Apache2::AuthzCaps
::rootdir
= $Apache2::Authen
::Passphrase
::rootdir
;
13 my $word = qr
,(\w
+),a
;
16 local $Log::Log4perl
::caller_depth
= $Log::Log4perl
::caller_depth
+ 1;
17 $_[0]->{'psgix.logger'}->({qw
/level debug message/ => $_[1]})
20 sub some_auth_required
{
21 my $r = Plack
::Request
->new($_[0]);
22 return 1 if $_[0]->{'gruntmaster.reqadmin'} || $r->path eq '/action/passwd' || $r->path =~ m
,/pb/$word/submit
$,;
28 return 1 if m
,^/pb/$word, && problem_private
$1;
29 return 1 if m
,^/log/(?
:job
|src
)/$word, && job_private
$1;
30 return 1 if m
,^/ct/$word/(?
:pb
|log), && time < contest_start
$1;
31 return 1 if m
,^/ct/$word/log/src
, && time < contest_end
$1;
38 *__ANON__
= "require_admin_middleware";
40 my $r = Plack
::Request
->new($env);
41 $env->{'gruntmaster.reqadmin'} = 1 if admin_required
$r->path;
49 my ($user, $pass, $env) = @_;
50 my $cache_key = sha256
"$user:$pass";
51 my $time = $authen_cache{$cache_key} // 0;
52 if ($time >= time - 300) {
55 delete $authen_cache{$cache_key};
62 $authen_cache{$cache_key} = time;
64 return if $env->{'gruntmaster.reqadmin'} && !hascaps
$user, 'gmadm';
69 enable
'ContentLength';
70 enable_if
{ $_[0]->{PATH_INFO
} =~ qr
,^/static/,} Header
=> set
=> ['Cache-Control', 'public, max-age=604800'];
71 enable
'Static', path
=> qr
,^/static/,;
72 enable
'Log4perl', category
=> 'plack', conf
=> 'log.conf';
73 enable \
&require_admin
;
74 enable_if \
&some_auth_required
, 'Auth::Basic', authenticator
=> \
&authenticate
, realm
=> 'Gruntmaster 6000';
75 Plack
::App
::Gruntmaster
->to_app
This page took 0.054059 seconds and 4 git commands to generate.