]> iEval git - apache2-authen-passphrase.git/blobdiff - lib/Apache2/Authen/Passphrase.pm
Bump version and update Changes
[apache2-authen-passphrase.git] / lib / Apache2 / Authen / Passphrase.pm
index ae8d01c7d33b0fb99871c71aa86fa13fa71d477f..229ff7925f63d6b825cadd7755cd4872ba407279 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 use parent qw/Exporter/;
 use subs qw/OK HTTP_UNAUTHORIZED/;
 
-our $VERSION = 0.002001;
+our $VERSION = 0.002002;
 
 use constant USER_REGEX => qr/^\w{2,20}$/pas;
 use constant PASSPHRASE_VERSION => 1;
@@ -14,6 +14,7 @@ use constant INVALID_USER => "invalid-user\n";
 use constant BAD_PASSWORD => "bad-password\n";
 
 use if $ENV{MOD_PERL}, 'Apache2::RequestRec';
+use if $ENV{MOD_PERL}, 'Apache2::RequestUtil';
 use if $ENV{MOD_PERL}, 'Apache2::Access';
 use if $ENV{MOD_PERL}, 'Apache2::Const' => qw/OK HTTP_UNAUTHORIZED/;
 use Authen::Passphrase;
@@ -28,56 +29,56 @@ our $rootdir;
 $rootdir //= $ENV{AAP_ROOTDIR};
 
 sub pwhash{
-  my ($pass)=@_;
+       my ($pass)=@_;
 
-  my $ppr=Authen::Passphrase::BlowfishCrypt->new(
-       cost => 10,
-       passphrase => $pass,
-       salt_random => 1,
-  );
+       my $ppr=Authen::Passphrase::BlowfishCrypt->new(
+               cost => 10,
+               passphrase => $pass,
+               salt_random => 1,
+       );
 
-  $ppr->as_rfc2307
+       $ppr->as_rfc2307
 }
 
 sub pwset{
-  my ($user, $pass)=@_;
+       my ($user, $pass)=@_;
 
-  my $file = "$rootdir/$user.yml";
-  my $conf = eval { LoadFile $file } // undef;
-  $conf->{passphrase}=pwhash $pass;
-  $conf->{passphrase_version}=PASSPHRASE_VERSION;
-  DumpFile $file, $conf;
+       my $file = "$rootdir/$user.yml";
+       my $conf = eval { LoadFile $file } // undef;
+       $conf->{passphrase}=pwhash $pass;
+       $conf->{passphrase_version}=PASSPHRASE_VERSION;
+       DumpFile $file, $conf;
 
-  chmod 0660, $file;
+       chmod 0660, $file;
 }
 
 sub pwcheck{
-  my ($user, $pass)=@_;
-  die INVALID_USER unless $user =~ USER_REGEX; ## no critic (RequireCarping)
-  $user=${^MATCH};# Make taint shut up
-  my $conf=LoadFile "$rootdir/$user.yml";
-
-  ## no critic (RequireCarping)
-  die BAD_PASSWORD unless keys $conf;# Empty hash means no such user
-  die BAD_PASSWORD unless Authen::Passphrase->from_rfc2307($conf->{passphrase})->match($pass);
-  ## use critic
-  pwset $user, $pass if $conf->{passphrase_version} < PASSPHRASE_VERSION
+       my ($user, $pass)=@_;
+       die INVALID_USER unless $user =~ USER_REGEX; ## no critic (RequireCarping)
+       $user=${^MATCH};                             # Make taint shut up
+       my $conf=LoadFile "$rootdir/$user.yml";
+
+       ## no critic (RequireCarping)
+       die BAD_PASSWORD unless keys %$conf;          # Empty hash means no such user
+       die BAD_PASSWORD unless Authen::Passphrase->from_rfc2307($conf->{passphrase})->match($pass);
+       ## use critic
+       pwset $user, $pass if $conf->{passphrase_version} < PASSPHRASE_VERSION
 }
 
 sub handler{
-  my $r=shift;
-  local $rootdir = $r->dir_config('AuthenPassphraseRootdir');
+       my $r=shift;
+       local $rootdir = $r->dir_config('AuthenPassphraseRootdir');
 
-  my ($rc, $pass) = $r->get_basic_auth_pw;
-  return $rc unless $rc == OK;
+       my ($rc, $pass) = $r->get_basic_auth_pw;
+       return $rc unless $rc == OK;
 
-  my $user=$r->user;
-  unless (eval { pwcheck $user, $pass; 1 }) {
-       $r->note_basic_auth_failure;
-       return HTTP_UNAUTHORIZED
-  }
+       my $user=$r->user;
+       unless (eval { pwcheck $user, $pass; 1 }) {
+               $r->note_basic_auth_failure;
+               return HTTP_UNAUTHORIZED
+       }
 
-  OK
+       OK
 }
 
 1;
@@ -177,7 +178,7 @@ Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (C) 2013 by Marius Gavrilescu
+Copyright (C) 2013-2015 by Marius Gavrilescu
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself, either Perl version 5.14.2 or,
This page took 0.028554 seconds and 4 git commands to generate.