Apache::Htgroup(3pm)
π Apache::Htgroup β bestie's guide to Apache authentication group files π
okay so this is Apache::Htgroup, a Perl module from the User Contributed Perl Documentation collection, and it's literally here to help you manage Apache authentication group files. let's get into it π«Ά
β¨ SYNOPSIS β¨
here's the whole vibe at a glance, no cap:
use Apache::Htgroup;
$htgroup = Apache::Htgroup->load($path_to_groupfile);
&do_something if $htgroup->ismember($user, $group);
$htgroup->adduser($user, $group);
$htgroup->deleteuser($user, $group);
$htgroup->deletegroup( $group );
$htgroup->save;
πΈ DESCRIPTION πΈ
it manages Apache htgroup files. that's the whole job bestie π
now, two things you need to know before you get attached:
- this is not a mod_perl module. just so we're clear.
- there's another module out there that does similar things, called
HTTPD::UserManage, and this one is the more simplistic of the two β it does not do all the things that one does. so if you need the deluxe version, you know where to look. no shade, just facts β¨
π METHODS π
these are the methods this module provides, one by one, no skips:
π« load
$htgroup = Apache::Htgroup->load($path_to_groupfile);
returns you an Apache::Htgroup object. that's it, that's the method π
π« new
$htgroup = Apache::Htgroup->new();
$htgroup = Apache::Htgroup->new( $path_to_groupfile );
creates a brand new, empty group file, main character energy. but okay here's the plot twist: if the file you named already exists, it loads the contents of that file instead. and if you pass no filename at all? you can create a group file purely in memory and save it later. build it, then ship it π¦
π« adduser
$htgroup->adduser( $username, $group );
adds the specified user to the specified group. slay π
π« deleteuser
$htgroup->deleteuser($user, $group);
removes the specified user from the group. bye bestie ππ
π« groups
$groups = $htgroup->groups;
returns a reference to a hash of the groups. the key is the name of the group, and each value is a hashref whose keys are the group members. (the author supposes there may be some variety of a members method in the future, if anyone thinks that would be useful. π so like, if you want it, speak up.)
it's expected that this method will not be called directly β it's provided as a convenience only.
and if you wanna see what that data structure actually looks like, the Internals section below has an example. iykyk β¨
π« reload
$self->reload;
if you haven't already called save(), you can call reload() and get back to the state of the object as it was loaded from the original file. it's giving undo button π
π« deletegroup
$self->deletegroup( 'GroupName' );
removes a group from the htgroup file. heads up tho: you'll need to call save afterward to commit this change back to the file. don't forget, or it never happened π
π« save
$htgroup->save;
$htgroup->save($file);
writes the current contents of the htgroup object back to the file. and if you hand it a $file argument, save will attempt to write to that location instead. obsessed π
π« ismember
$foo = $htgroup->ismember($user, $group);
returns true if the username is in the group, false otherwise. vibe check for membership, fr fr β
π§ Internals π§
okay so this was not the case in earlier versions, but the internal data structure of the object looks something like this:
$obj = { groupfile => '/path/to/groupfile',
groups => { group1 => { 'user1' => 1,
'user2' => 1,
'user3' => 1
},
group2 => { 'usera' => 1,
'userb' => 1,
'userc' => 1
},
}
};
β οΈ real talk: this data structure is subject to change in the future. it's provided mostly so that the author can remember what the heck he was thinking when he next has to look at this code. π iconic honestly.
π Adding groups π
a number of folks have asked for a method to add a new group. bestie, it's unnecessary. β¨
to add a new group, you just start adding users to a new group, and the new group will magically spring into existence. no extra method, no ceremony, it just manifests. periodt π π
π AUTHOR π
Rich Bowen, rbowen@rcbowen.com
π COPYRIGHT π
Copyright (c) 2001 Rich Bowen. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
and that's the whole page bestie π«Ά this was perl v5.38.2, dated 2024-03-04, and it's the Apache::Htgroup(3pm) manual β go forth and manage those group files, you absolute legend ππ
π¦ where this page comes from
- debian trixie: libapache-htgroup-perl 1.23-4 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- ubuntu noble: libapache-htgroup-perl 1.23-4 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- ubuntu resolute: libapache-htgroup-perl 1.23-4 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- ubuntu stonking: libapache-htgroup-perl 1.23-4 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms