NAME
Apache::Htpasswd - Manage Unix crypt-style password file.
SYNOPSIS
use Apache::Htpasswd;
$foo = new Apache::Htpasswd("path-to-file");
# Add an entry
$foo->htpasswd("zog", "password");
# Change a password
$foo->htpasswd("zog", "new-password", "old-password");
# Change a password without checking against old password
# The 1 signals that the change is being forced.
$foo->htpasswd("zog", "new-password", 1);
# Check that a password is correct
$pwdFile->htCheckPassord("zog", "password");
# Fetch an encrypted password
$foo->fetchPass("foo");
# Delete entry
$foo->htDelete("foo");
# If something fails, check error
$foo->error;
DESCRIPTION
This module comes with a set of methods to use with htaccess password files. These files (and htaccess) are used to do Basic Authentication on a web server.
The passwords file is a flat-file with login name and their associated crypted password.
FUNCTIONS
- htaccess->new("path-to-file");
-
"path-to-file" should be the path and name of the file containing the login/password information.
- error;
-
If a method returns an error, or a method fails, the error can be retrived by calling error()
- htCheckPassword("login", "password");
-
Finds if the password is valid for the given login.
Returns 1 if passes. Returns 0 if fails.
- htpasswd("login", "password");
-
This will add a new user to the password file. Returns 1 if succeeds. Returns undef on failure.
- htDelete("login")
-
Delete users entry in password file.
Returns 1 on success Returns undef on failure.
- htpasswd("login", "new-password", "old-password");
-
If the old-password matches the login's password, then it will replace it with new-password. If the old-password is not correct, will return 0.
- htpasswd("login", "new-password", 1);
-
Will replace the password for the login. This will force the password to be changed. It does no verification of old-passwords.
Returns 1 if succeeds Returns undef if fails
- fetchPassword("login");
-
Returns encrypted password if succeeds. Returns 0 if login is invalid. Returns undef otherwise.
- CryptPasswd("password", "salt");
-
Will return an encrypted password using 'crypt'. If salt is ommitted, a salt will be given by the subroutine using the first 2 character of $0.
INSTALLATION
You install Apache::Htpasswd, as you would install any perl module library, by running these commands:
perl Makefile.PL
make
make test
make install
make clean
DOCUMENTATION
POD style documentation is included in the module. These are normally converted to manual pages and installed as part of the "make install" process. You should also be able to use the 'perldoc' utility to extract and read documentation from the module files directly.
AVAILABILITY
The latest version of Apache::Htpasswd should always be available from:
$CPAN/modules/by-authors/id/K/KM/KMELTZ/
Visit <URL:http://www.perl.com/CPAN/> to find a CPAN site near you.
VERSION
$Revision: 1.1 $ $Date: 1998/10/22 03:12:08 $
CHANGES
$Log: Htpasswd.pm,v $ Revision 1.1 1998/10/22 03:12:08 meltzek Slightly changed how files lock. Made more use out of carp and croak. Made sure there were no ^M's as per Randal Schwartz's request.
BUGS
None knows at time of writting.
AUTHOR INFORMATION
Copyright 1998, Kevin Meltzer. All rights reserved. It may be used and modified freely, but I do request that this copyright notice remain attached to the file. You may modify this module as you wish, but if you redistribute a modified version, please attach a note listing the modifications you have made.
Address bug reports and comments to: kmeltz@cris.com
The author makes no warranties, promises, or gaurentees of this software. As with all software, use at your own risk.