Apache2::Authen::Passphrase - basic authentication with Authen::Passphrase
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" }; # In Apache2 config <Location /secret> PerlAuthenHandler Apache2::Authen::Passphrase PerlSetVar AuthenPassphraseRootdir /path/to/user/directory AuthName MyAuth Require valid-user </Location>
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 rootdir), one file per user.
rootdir
Set the rootdir like this:
$Apache2::Authen::Passphrase::rootdir = '/path/to/rootdir';
or by setting the AAP_ROOTDIR enviroment variable to the desired value.
AAP_ROOTDIR
Takes the password as a single argument and returns the password hash.
Sets the password of $username to $password.
Checks the given username and password, throwing an exception if the username is invalid or the password is incorrect.
The PerlAuthenHandler for use in apache2. It uses Basic Access Authentication.
A regex that matches valid usernames. Usernames must be at least 2 characters, at most 20 characters, and they may only contain word characters ([A-Za-z0-9_]).
[A-Za-z0-9_]
Exception thrown if the username does not match USER_REGEX.
USER_REGEX
Exception thrown if the password is different from the one stored in the user's yml file.
The version of the passphrase. It is incremented each time the passphrase hashing scheme is changed. Versions so far:
Uses Authen::Passphrase::BlowfishCrypt with a cost factor of 10
Authen::Passphrase::BlowfishCrypt
If the rootdir is not explicitly set, it is taken from this environment variable.
Marius Gavrilescu, <marius@ieval.ro>
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, at your option, any later version of Perl 5 you may have available.
To install Apache2::Authen::Passphrase, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Apache2::Authen::Passphrase
CPAN shell
perl -MCPAN -e shell install Apache2::Authen::Passphrase
For more information on module installation, please visit the detailed CPAN module installation guide.