use Plack::App::Gruntmaster;
use Plack::Builder;
use Plack::Request;
+use Digest::SHA qw/sha256/;
$Apache2::AuthzCaps::rootdir = $Apache2::Authen::Passphrase::rootdir;
my $word = qr,(\w+),a;
}
}
+my %authen_cache;
+
sub authenticate {
my ($user, $pass, $env) = @_;
+ my $cache_key = sha256 "$user:$pass";
+ my $time = $authen_cache{$cache_key} // 0;
+ if ($time >= time - 300) {
+ return 1;
+ } else {
+ delete $authen_cache{$cache_key};
+ }
+
return unless eval {
pwcheck $user, $pass;
1
};
+ $authen_cache{$cache_key} = time;
return if $env->{'gruntmaster.reqadmin'} && !hascaps $user, 'gmadm';
1