Authen...::User(3pm)
π Authen::Htpasswd::User π
okay so bestie, this is a page from the User Contributed Perl Documentation, and it's literally about Authen::Htpasswd::User β which is the lil' object that represents one single user line inside a .htpasswd file. that's it, that's the whole vibe. one user, one line, so much power. π
β¨ NAME β¨
Authen::Htpasswd::User β represents a user line in a .htpasswd file π«Ά
πΈ SYNOPSIS πΈ
my $user = Authen::Htpasswd::User->new($username, $password[, @extra_info], \%options);
my $user = $pwfile->lookup_user($username); # from Authen::Htpasswd object
if ($user->check_password($password)) { ... }
if ($user->hashed_password eq $foo) { ... }
# these are written immediately if the user was looked up from an Authen::Htpasswd object
$user->username('bill');
$user->password('bar');
$user->hashed_password('tIYAwma5mxexA');
$user->extra_info('root', 'joe@site.com', 'Joe Sysadmin');
$user->set(username => 'bill', password => 'foo'); # set several at once
print $user->to_line, "\n";
likeβ¦ look at that. it's giving object-oriented elegance. no cap. β¨
π¦ METHODS π¦
π new
my $userobj = Authen::Htpasswd::User->new($username, $password[, @extra_info], \%options);
this is the birth of a user object. iconic. π
you can also hand over the args and options all mushed together in one hash, like this:
{ username => $foo, password => $bar, extra_info => [$email, $name], ... }
so whichever way you like to feed it, it's fed. π
π encrypt_hash
π check_hashes
okay so these two? go read Authen::Htpasswd. that's where they live. β¨
π hashed_password
this one explicitly sets the value of the hashed password, instead of generating it for you via password. like, you already did the math, bestie, so here's the answer. π
π check_password
$userobj->check_password($password,\@check_hashes);
returns whether the password matches or not. that's it. yes/no. slay or no slay.
check_hashes works exactly the same as it does for Authen::Htpasswd, iykyk.
π username
π hashed_password
π extra_info(@fields)
get and set the fields of the user line. these three, plus password and set down below, write any changes immediately if the user was looked up from an Authen::Htpasswd object. so like, no "save" button. it's instant. main character energy fr fr.
β οΈ and if you change the username? the old entry is NOT preserved. it's gone. ghosted. π
π password
$userobj->password($newpass);
encrypts a new password for you. π
β οΈ heads up bestie: it DIES if $newpass is not provided. so like, actually pass the password. π
β set
$userobj->set(item => $value, ...);
sets any of the four values above all at once. and the cute part? if the file is gonna be written, it only writes it once. efficiency queen. π
π to_line
$userobj->to_line;
returns a line for the user that's suitable for printing straight into a .htpasswd file.
β οΈ there is no newline at the end. so if you want one, add it yourself. the SYNOPSIS up top shows you how. π«Ά
π AUTHOR π
David Kamholz dkamholz@cpan.org
Yuval Kogman
π COPYRIGHT & LICENSE π
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.
okay that's the whole page, bestie, we ate and left no crumbs. πβ¨ this lil' slice of wisdom was cooked up on 2022-11-20 and ships with perl v5.36.0. mwah, go write some .htpasswd files responsibly. π
ππ¦
π¦ where this page comes from
- debian bookworm: libauthen-htpasswd-perl 0.171-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libauthen-htpasswd-perl 0.171-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libauthen-htpasswd-perl 0.171-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libauthen-htpasswd-perl 0.171-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libauthen-htpasswd-perl 0.171-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms