]> iEval git - apache2-authen-passphrase.git/blobdiff - lib/Apache2/Authen/Passphrase.pm
Make mod_perl optional
[apache2-authen-passphrase.git] / lib / Apache2 / Authen / Passphrase.pm
index 4beea0e0e8e10160a55465c48cbbb1ea7a923122..e8a157991eba0dfd3c30549583feae52326eee4b 100644 (file)
@@ -1,9 +1,12 @@
-package Apache2::Authen::Passphrase 0.001001;
+package Apache2::Authen::Passphrase;
+
+our $VERSION = 0.002;
 
 use 5.014000;
 use strict;
 use warnings;
 use parent qw/Exporter/;
+use subs qw/OK HTTP_UNAUTHORIZED/;
 
 use constant +{
   USER_REGEX => qr/^\w{2,20}$/pa,
@@ -12,9 +15,9 @@ use constant +{
   BAD_PASSWORD => "bad-password\n",
 };
 
-use Apache2::RequestRec;
-use Apache2::Access;
-use Apache2::Const qw/OK HTTP_UNAUTHORIZED/;
+use if $ENV{MOD_PERL}, 'Apache2::RequestRec';
+use if $ENV{MOD_PERL}, 'Apache2::Access';
+use if $ENV{MOD_PERL}, 'Apache2::Const' => qw/OK HTTP_UNAUTHORIZED/;
 use Authen::Passphrase;
 use Authen::Passphrase::BlowfishCrypt;
 use YAML::Any qw/LoadFile DumpFile/;
@@ -23,7 +26,7 @@ our @EXPORT_OK = qw/pwset pwcheck pwhash USER_REGEX PASSPHRASE_VERSION INVALID_U
 
 ##################################################
 
-our $rootdir;
+our $rootdir //= $ENV{AAP_ROOTDIR};
 
 sub pwhash{
   my ($pass)=@_;
@@ -103,6 +106,14 @@ Apache2::Authen::Passphrase - basic authentication with Authen::Passphrase
 
 Apache2::Authen::Passphrase is a perl module which provides easy-to-use Apache2 authentication. It exports some utility functions and it contains a PerlAuthenHandler.
 
+The password hashes are stored in YAML files in an directory (called the C<rootdir>), one file per user.
+
+Set the C<rootdir> like this:
+
+  $Apache2::Authen::Passphrase::rootdir = '/path/to/rootdir';
+
+or by setting the C<AAP_ROOTDIR> enviroment variable to the desired value.
+
 =head1 FUNCTIONS
 
 =over
@@ -149,6 +160,16 @@ Uses C<Authen::Passphrase::BlowfishCrypt> with a cost factor of 10
 
 =back
 
+=head1 ENVIRONMENT
+
+=over
+
+=item AAP_ROOTDIR
+
+If the C<rootdir> is not explicitly set, it is taken from this environment variable.
+
+=back
+
 =head1 AUTHOR
 
 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
This page took 0.025155 seconds and 4 git commands to generate.