Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??


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.

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

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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?

    What's my password?
    Create A New User
    thezip looks around to see no one else dancing to Piazzola...
    [thezip]: Our cat is single-handedly (pawed-ly?) solving our field mouse problem. About four critters in the last week alone.
    [thezip]: Amazing speed and stealth in that one.
    [GotToBTru]: You can't tunafish, but some seafood companies can tunafish. More fun with English.

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (15)
    As of 2017-11-17 19:48 GMT
    Find Nodes?
      Voting Booth?
      In order to be able to say "I know Perl", you must have:

      Results (272 votes). Check out past polls.