in reply to Authentication in web applications
Hello,
You argue that CGI-based authentication requires a lot of attention from the programmer, and that you need to ensure that you don't miss any execution path... But this all can be solved in the application desgin before you delve into the code.
Here's one of the ways I would tackle this:
You need users and groups of permission, even if you seem not to need groups, you need at least two groups: visitor, and user. The visitor group has the permission to read some pages only, it is the default group and only contains one user (the not-logged-in visitor). The "user" group has other types of permissions, and that's usually a logged in user.
In order to apply this, you need to always populate the permissions of the user on each request, so it will look like this:
# some initialization code. $object->login(); # then you continue your application $object->open_some_page(); # more stuff.
The login() method will check for parameters/cookies/etc.. and handle the sessions, AND it will populate some objects regarding the user login. ex: $object->{user}->{permission} contains the permission of the user.
Now wherever you need to perform operations that require permissions, you only need to check $object->{user}->{permission} cause you are sure that this contains the correct permissions wherever you are in the code, provided that you call login() as soon as you can.
Hope this gives you some more ideas to consider.
|
|---|