README
1NAME
2 Apache::Htgroup - Manage Apache authentication group files
3
4SYNOPSIS
5 use Apache::Htgroup;
6 $htgroup = Apache::Htgroup->load($path_to_groupfile);
7 &do_something if $htgroup->ismember($user, $group);
8 $htgroup->adduser($user, $group);
9 $htgroup->deleteuser($user, $group);
10 $htgroup->deletegroup( $group );
11 $htgroup->save;
12
13DESCRIPTION
14 Manage Apache htgroup files
15
16 Please note that this is *not* a mod_perl module. Please also note that
17 there is another module that does similar things (HTTPD::UserManage) and
18 that this is a more simplistic module, not doing all the things that one
19 does.
20
21 METHODS
22 The following methods are provided by this module.
23
24 load
25 $htgroup = Apache::Htgroup->load($path_to_groupfile);
26
27 Returns an Apache::Htgroup object.
28
29 new
30 $htgroup = Apache::Htgroup->new();
31 $htgroup = Apache::Htgroup->new( $path_to_groupfile );
32
33 Creates a new, empty group file. If the specified file already exists,
34 loads the contents of that file. If no filename is specified, you can
35 create a group file in memory, and save it later.
36
37 adduser
38 $htgroup->adduser( $username, $group );
39
40 Adds the specified user to the specified group.
41
42 deleteuser
43 $htgroup->deleteuser($user, $group);
44
45 Removes the specified user from the group.
46
47 groups
48 $groups = $htgroup->groups;
49
50 Returns a (reference to a) hash of the groups. The key is the name of
51 the group. Each value is a hashref, the keys of which are the group
52 members. I suppose there may be some variety of members method in the
53 future, if anyone thinks that would be useful.
54
55 It is expected that this method will not be called directly, and it is
56 provided as a convenience only.
57
58 Please see the section below about internals for an example of the data
59 structure.
60
61 reload
62 $self->reload;
63
64 If you have not already called save(), you can call reload() and get
65 back to the state of the object as it was loaded from the original file.
66
67 deletegroup
68 $self->deletegroup( 'GroupName' );
69
70 Removes a group from the htgroup file. You will need to call save
71 afterward to commit this change back to the file.
72
73 save
74 $htgroup->save;
75 $htgroup->save($file);
76
77 Writes the current contents of the htgroup object back to the file. If
78 you provide a $file argument, "save" will attempt to write to that
79 location.
80
81 ismember
82 $foo = $htgroup->ismember($user, $group);
83
84 Returns true if the username is in the group, false otherwise
85
86Internals
87 Although this was not the case in earlier versions, the internal data
88 structure of the object looks something like the following:
89
90 $obj = { groupfile => '/path/to/groupfile',
91 groups => { group1 => { 'user1' => 1,
92 'user2' => 1,
93 'user3' => 1
94 },
95 group2 => { 'usera' => 1,
96 'userb' => 1,
97 'userc' => 1
98 },
99 }
100 };
101
102 Note that this data structure is subject to change in the future, and is
103 provided mostly so that I can remember what the heck I was thinking when
104 I next have to look at this code.
105
106Adding groups
107 A number of folks have asked for a method to add a new group. This is
108 unnecessary. To add a new group, just start adding users to a new group,
109 and the new group will magically spring into existance.
110
111AUTHOR
112 Rich Bowen, rbowen@rcbowen.com
113
114COPYRIGHT
115 Copyright (c) 2001 Rich Bowen. All rights reserved. This program is free
116 software; you can redistribute it and/or modify it under the same terms
117 as Perl itself.
118
119 The full text of the license can be found in the LICENSE file included
120 with this module.
121
122