X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FApache2%2FAuthen%2FPassphrase.pm;fp=lib%2FApache2%2FAuthen%2FPassphrase.pm;h=4beea0e0e8e10160a55465c48cbbb1ea7a923122;hb=f7fdbaad4baa1b241e5f5bfa30c7585abb10b0bd;hp=0770f74a72fc879403ff01f910a5d66e4e67b094;hpb=f4cc782bb1ff3f0c0479999547e7146452d11c33;p=apache2-authen-passphrase.git diff --git a/lib/Apache2/Authen/Passphrase.pm b/lib/Apache2/Authen/Passphrase.pm index 0770f74..4beea0e 100644 --- a/lib/Apache2/Authen/Passphrase.pm +++ b/lib/Apache2/Authen/Passphrase.pm @@ -1,4 +1,4 @@ -package Apache2::Authen::Passphrase 0.001; +package Apache2::Authen::Passphrase 0.001001; use 5.014000; use strict; @@ -40,7 +40,7 @@ sub pwhash{ sub pwset{ my ($user, $pass)=@_; - my $file = "$rootdir/us/$user.yml"; + my $file = "$rootdir/$user.yml"; my $conf = eval { LoadFile $file } // undef; $conf->{passphrase}=pwhash $pass; $conf->{passphrase_version}=PASSPHRASE_VERSION; @@ -53,7 +53,7 @@ sub pwcheck{ my ($user, $pass)=@_; die INVALID_USER unless $user =~ USER_REGEX; $user=${^MATCH};# Make taint shut up - my $conf=LoadFile "$rootdir/us/$user.yml"; + my $conf=LoadFile "$rootdir/$user.yml"; die BAD_PASSWORD unless keys $conf;# Empty hash means no such user die BAD_PASSWORD unless Authen::Passphrase->from_rfc2307($conf->{passphrase})->match($pass); @@ -62,6 +62,7 @@ sub pwcheck{ sub handler{ my $r=shift; + local $rootdir = $r->dir_config('AuthenPassphraseRootdir'); my ($rc, $pass) = $r->get_basic_auth_pw; return $rc unless $rc == OK; @@ -85,6 +86,7 @@ Apache2::Authen::Passphrase - basic authentication with Authen::Passphrase =head1 SYNOPSIS use Apache2::Authen::Passphrase qw/pwcheck pwset pwhash/; + $Apache2::Authen::Passphrase::rootdir = "/path/to/user/directory" my $hash = pwhash $username, $password; pwset $username, "pass123"; eval { pwcheck $username, "pass123" }; @@ -92,6 +94,7 @@ Apache2::Authen::Passphrase - basic authentication with Authen::Passphrase # In Apache2 config PerlAuthenHandler Apache2::Authen::Passphrase + PerlSetVar AuthenPassphraseRootdir /path/to/user/directory AuthName MyAuth Require valid-user