views:

81

answers:

3

I'm very new to Perl, and I have absolutely no idea how to approach this. We have an old Perl application which previously used Apache auth; we'd like to replace this with a cookie based form-style authentication. I understand that this is very case-specific, and there is no one answer as such, but some general tips would be much appreciated.

Will I need to edit all .pl files in the website? Or is there a "golden hammer" solution I can use? Is there something on CPAN I can use? We're using Perl v5.8.8 if it matters, and we're using Apache 2 shared hosting. I am happy to provide additional information as is necessary.

A: 

You could do it at a level outside the Perl program.

David Dorward
Does this work on shared hosting?
nbolton
Depends how much control the host provides (and how much they are willing to do on your behalf)
David Dorward
+1  A: 

For the authentication to be recognized/required, it will need to be checked by the .pl file that initially receives the user's request. So the answer to whether all .pl files will need to be changed depends on how your application is structured:

Edited to add: If you're dealing with the first model, then I'd strongly recommend setting up an external module (.pm file) with the cookie-handling code and calling that from each of your individual .pl files instead of duplicating that code all over the place. Ideally, this would let you get by with only a few lines of added code in each .pl:

use MyCookieHandlingModule qw(verify_cookie redirect_to_login);
my $q = CGI->new;  # ...unless you're already using CGI in object-oriented mode
redirect_to_login unless verify_cookie($q);
Dave Sherohman
A: 

Thanks for your answers guys, but I eventually decided on CGI::Session::Auth::DBI which works well on shared hosting.

nbolton