Apache::Htgroup(3pm)

πŸ“¦
version 1.23 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 (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