User module

[ download ] [ xml source ] [ discussion ]

The user module is used by the various parts of the wftk both for authorizing users and for storing information about users and the things they work with. To do this, we maintain XML documents, one for each user and one for each group. A group in this context contains both a list of users and a list of objects. The objects are defined pretty vaguely; since the programs which handle those objects will be querying the user module for levels of access, those programs are assumed to know what they're doing. So basically I'm giving objects a module name (a namespace, really) and an identifier.

A group may contain other groups; the contained groups may thus be seen as folders (even though they may simultaneously serve as groups of users, the folder metaphor is more apt for contained groups.) In this case, the permission used on the link combines with the permission the contained group has on the object thus: (x) + own = (x), own + (x) = (x), (x) + (x) = (x), and (x) + (y) = nothing. So let's assume that group "myfolder" has permission "own" on object "MyDocument". If I grant group "friends" permission "view" on myfolder, then they end up with view + own = view on MyDocument. Anybody with "view" privilege on "friends" thus acquires viewing privileges on MyDocument.

A group or user may also be considered as an object, of course, and that's how we grant admin privileges. If I grant somebody viewing privileges on the "friends" folder above, as an object, then they can view the actual friends folder and its contents, but they do not thereby acquire any privileges to MyDocument.

This explanation is pretty weak, so I'm going to let it sit a few days and start again.

This module defines three files. First, of course, is user.c, which is simply the implementation of the functionality. This file should be compiled along with your project. The obligatory declarations are of course in user.h. Finally, main.c defines a main program and simple command-line interface, resulting in a command-line user maintenance utility.

I've written a folder browser based on this user library. Take a look at it for an idea of how to use the library.

Table of contents:

This code and documentation are released under the terms of the GNU license. They are additionally copyright (c) 2000, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license. This presentation was prepared using LPML.