Note: you must use Access::add() and etc in order to call the subroutines of this package It doesn't let you import the subroutines' names to your script namespace because of very high risk of name collision (its add, remove, dump and query)
DB Name
Once the filling of the DB is started webmaster can change the cgi scripts' authentication mechanism to make a query to DB with these 4 parameters and get 'Access granted' or 'denied' upon the DB records.
To ease the DB management, macros have been introduced.
User can be granted to perform anything by setting add($user,'all'). To allow user to use any tool on specific directory use add($user, $dir, 'all'). To allow user to use any action of specific tool on specific directory do add($user, $dir, $tool, 'all').
The reverse macros are for permission removal: remove($user, 'all') will remove any rights that has been assigned to $user. The same logic for remove($user, $dir, 'all') and remove($user, $dir, $tool, 'all')
To printout a piece of DB use dump(). dump() will print the whole DB, dump($user) will dump permission table for $user, dump($user, $dir) will dump permission table for $user on $dir, dump($user, $dir, $tool) will dump permission table for $user on $dir for $tool.
Important: You can't assign to some field 'all' value with add() and then to try to make delete() on the same field with non all value. The package just don't know what are the complement values to 'all'. To make it clear check this:
If the package would know what are the values for group substruction 'all'-'read' (e.g. write, execute) it was possible to assign the complement values to 'read'...
But it will work perfectly in the other way:
Additional abstraction: a lot of user_names are being mapped to one group_name
Imagine that you want to fill the db with many users who all belongs to the same group and you want to assign to all of them the same access rights. It a good idea to add one group name instead of all these users who belong to the same group. Now the maintaince is easy -- since you don't have to keep track of new users who just joined a ``project'' or users who left it and no more allowed to get access rights to specific resource.
How does it works in Access:
It's absolutely transparent to the user of this ``application''. If you want to perform add, delete or dump command with group_name you do it the same way you did before with user name. The only difference is now that when you make a query of user query routine first checks the DB for the entry of real username. If the query is successfull -- the 4 levels of user-dir-tool-action has been set the query is over as before. If not -- a user to group resolver is being called , which returns the list of groups the user belongs to, then it queries for each group_name in that list to see if there is a match. If so -- the query is finished and 1 returned , else the tool loops thru the list of groups and calls the subquery till it gets the match or the list is over.
Once we perform insert/modify we must use $tmp value because of limitation of multidimensional array storage [MLDBM]. We use it only in delete/modify subroutines