Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello,
When you use Apache's AuthType Basic and apache uses mod_auth to prompt for user name and password
(generally referred to as htaccess control) the user is stored for the duration of the browser session.
Is there any way of emulating this with Mason (perl)
Currently I'm using a different approach, but I'd like to have it so that I can specify that the user is logged in,
and then not have to worry about passing around variables to say that they are logged in.
(Mason is perl for anyone that doesn't know)

Thanks

Gareth Kirwan gbjk@carsplus.co.uk

Replies are listed 'Best First'.
Re: User authentication
by davis (Vicar) on Mar 20, 2002 at 12:12 UTC
    Hi
    Having just finished a project using it, I can whole heartedly recommend Apache::AuthCookie, which can protect whole directories, just like AuthBasic
    It's also got the advantage of allowing users to logout, unlike authbasic.
    Note: I have no experience with Mason, but you will need mod_perl with StackedHandlers, MethodHandlers, Authen, and Authz compiled in.
    On another note, you may wish to try typing session or authenticate in the search box.
    hope this helps
    davis
    Is this going out live?
    No, Homer, very few cartoons are broadcast live - it's a terrible strain on the animator's wrist
Re: User authentication
by dreadpiratepeter (Priest) on Mar 20, 2002 at 15:28 UTC
    The way I implemented this in Mason is to have a perl block at the top of my autohandler that redirects the user to the login page if he is not valid. The login page has code that redirects the user to the main page if he is already logged in.
    I use session variables to store login status so I don't need to pass any information around.
    Because it is in the autohandler, I don't have to code the security for individual pages, plus if someone bookmarks a page deep in the system, he can't use it to get around security.

    -pete
    "I am Jack's utter lack of disbelief"