.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Authen::Htpasswd 3pm" .TH Authen::Htpasswd 3pm "2022-11-20" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Authen::Htpasswd \- interface to read and modify Apache .htpasswd files .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& my $pwfile = Authen::Htpasswd\->new(\*(Aquser.txt\*(Aq, { encrypt_hash => \*(Aqmd5\*(Aq }); \& \& # authenticate a user (checks all hash methods by default) \& if ($pwfile\->check_user_password(\*(Aqbob\*(Aq, \*(Aqfoo\*(Aq)) { ... } \& \& # modify the file (writes immediately) \& $pwfile\->update_user(\*(Aqbob\*(Aq, $password, $info); \& $pwfile\->add_user(\*(Aqjim\*(Aq, $password); \& $pwfile\->delete_user(\*(Aqjim\*(Aq); \& \& # get user objects tied to a file \& my $user = $pwfile\->lookup_user(\*(Aqbob\*(Aq); \& if ($user\->check_password(\*(Aqvroom\*(Aq, [qw/ md5 sha1 /])) { ... } # only use secure hashes \& $user\->password(\*(Aqfoo\*(Aq); # writes to file \& $user\->set(password => \*(Aqbar\*(Aq, extra_info => \*(Aqeditor\*(Aq); # change more than one thing at once \& \& # or manage the file yourself \& my $user = Authen::Htpasswd::User\->new(\*(Aqbill\*(Aq, { hashed_password => \*(AqiQ.IuWbUIhlPE\*(Aq }); \& my $user = Authen::Htpasswd::User\->new(\*(Aqbill\*(Aq, \*(Aqbar\*(Aq, \*(Aqstaff\*(Aq, { encrypt_hash => \*(Aqcrypt\*(Aq }); \& print PASSWD $user\->to_line, "\en"; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides a convenient, object-oriented interface to Apache-style \&\fI.htpasswd\fR files. .PP It supports passwords encrypted via \s-1MD5, SHA\-1,\s0 and crypt, as well as plain (cleartext) passwords. .PP Additional fields after username and password, if present, are accessible via the \f(CW\*(C`extra_info\*(C'\fR array. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" .Vb 1 \& my $pwfile = Authen::Htpasswd\->new($filename, \e%options); .Ve .PP Creates an object for a given \fI.htpasswd\fR file. Options: .IP "encrypt_hash" 4 .IX Item "encrypt_hash" How passwords should be encrypted if a user is added or changed. Valid values are \f(CW\*(C`md5\*(C'\fR, \f(CW\*(C`sha1\*(C'\fR, \&\f(CW\*(C`crypt\*(C'\fR, and \f(CW\*(C`plain\*(C'\fR. Default is \f(CW\*(C`crypt\*(C'\fR. .IP "check_hashes" 4 .IX Item "check_hashes" An array of hash methods to try when checking a password. The methods will be tried in the order given. Default is \f(CW\*(C`md5\*(C'\fR, \f(CW\*(C`sha1\*(C'\fR, \f(CW\*(C`crypt\*(C'\fR, \f(CW\*(C`plain\*(C'\fR. .SS "lookup_user" .IX Subsection "lookup_user" .Vb 1 \& my $userobj = $pwfile\->lookup_user($username); .Ve .PP Returns an Authen::Htpasswd::User object for the given user in the password file. .SS "all_users" .IX Subsection "all_users" .Vb 1 \& my @users = $pwfile\->all_users; .Ve .SS "check_user_password" .IX Subsection "check_user_password" .Vb 1 \& $pwfile\->check_user_password($username,$password); .Ve .PP Returns whether the password is valid. Shortcut for \&\f(CW\*(C`$pwfile\->lookup_user($username)\->check_password($password)\*(C'\fR. .SS "update_user" .IX Subsection "update_user" .Vb 2 \& $pwfile\->update_user($userobj); \& $pwfile\->update_user($username, $password[, @extra_info], \e%options); .Ve .PP Modifies the entry for a user saves it to the file. If the user entry does not exist, it is created. The options in the second form are passed to Authen::Htpasswd::User. .SS "add_user" .IX Subsection "add_user" .Vb 2 \& $pwfile\->add_user($userobj); \& $pwfile\->add_user($username, $password[, @extra_info], \e%options); .Ve .PP Adds a user entry to the file. If the user entry already exists, an exception is raised. The options in the second form are passed to Authen::Htpasswd::User. .SS "delete_user" .IX Subsection "delete_user" .Vb 2 \& $pwfile\->delete_user($userobj); \& $pwfile\->delete_user($username); .Ve .PP Removes a user entry from the file. .SH "AUTHOR" .IX Header "AUTHOR" David Kamholz \f(CW\*(C`dkamholz@cpan.org\*(C'\fR .PP Yuval Kogman .SH "SEE ALSO" .IX Header "SEE ALSO" Apache::Htpasswd. .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" .Vb 1 \& Copyright (c) 2005 \- 2007 the aforementioned authors. \& \& This program is free software; you can redistribute \& it and/or modify it under the same terms as Perl itself. .Ve