![]() |
|
Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Authentication in web applicationsby Chady (Priest) |
on Jun 08, 2005 at 07:20 UTC ( #464578=note: print w/replies, xml ) | Need Help?? |
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:
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. He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life. Chady | http://chady.net/
Are you a Linux user in Lebanon? join the Lebanese GNU/Linux User Group.
In Section
Meditations
|
|