Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Comment on

( #3333=superdoc: 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:

# 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 | http://chady.net/
Are you a Linux user in Lebanon? join the Lebanese GNU/Linux User Group.

In reply to Re: Authentication in web applications by Chady
in thread Authentication in web applications by polettix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (13)
    As of 2014-11-28 08:39 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (194 votes), past polls