You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Alexander Burrows <al...@yahoo.com> on 2007/12/01 02:10:14 UTC

Re: Auth Question need some input

Thanks. You guys have been a great help. I'm going to use Apache 2 and
mod_perl 2 for my next project so I'm sure you'll hear more from me as I've
never touched it. Looks like most of it is backwards compatible though and
when in doubt changing Apache:: to Apache2:: looks like it will work most of
the time =)

-Alexander


Alexander Burrows wrote:
> 
> Alright I have been sitting on the side lines of learning anything new
> about mod_perl for too long. So I hope I've come to the right place to get
> brushed up on things. I'll be diving into mod_perl 2 and apache 2 soon but
> need to get some things working in mod perl 1 first.
> 
> I'm working on a user based system that will require login and password. I
> know there is about a million ways i can think to do this but want to
> learn the best. In the end I would like to have sessions and lockout based
> on time of day.
> 
> The two ways I can think of are building my own mod and using on the pages
> I want to restrict in this fashion. For this method I would not need much
> help. The way I would like to do it but lack a greater knowledge of is
> perlauthenhandler. I gave this a shot with the little bits I could find on
> the net and I can not seem to get it working. I have ordered the mod_perl
> cookbook but have not received it yet.
> 
> I just tried a very basic one to start with that would check a cookie and
> redirect you to a login page if it was not there. The redirect would not
> work and I would get a forbidden message from the server. Here is the code
> I tried. Please be gentle it has been a while haha.
> 
> sub handler {
>   my $r = Apache::Request->new(shift);
> 
>   my $cookie = Apache::Cookie->fetch();
> 
>   my %auth = $cookie->{'auth'}->value();
>   
>   unless ( $auth{'id'} ) {
>     $r->headers_out->set(Location => '/sys-bin/login.cgi');
>     $r->status(REDIRECT);
>     return REDIRECT;
>     exit 1;
>   } else {
>     $r->headers_out->set(Location => '/sys-bin/search/search.cgi');
>     $r->status(REDIRECT);
>     return REDIRECT;
>     exit 1;
>   }
> 
> }
> 
> -Alexander
> 

-- 
View this message in context: http://www.nabble.com/Auth-Question-need-some-input-tf4878626.html#a14100966
Sent from the mod_perl - General mailing list archive at Nabble.com.