Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.

Re: Authentication in web applications

by Chady (Priest)
on Jun 08, 2005 at 07:20 UTC ( #464578=note: print w/replies, xml ) Need Help??

in reply to Authentication in web applications


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.

He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.
Chady |
Are you a Linux user in Lebanon? join the Lebanese GNU/Linux User Group.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://464578]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2023-11-30 06:39 GMT
Find Nodes?
    Voting Booth?

    No recent polls found