You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by James G Smith <JG...@TAMU.Edu> on 2000/10/22 01:58:17 UTC

Re: simple cookie authorization?

Jason Bodnar <jb...@buzzard.kdi.com> wrote:
>Is there a module for simple cookie authorization? I want to grant access if
>the user has a cookie set. I don't care about the value of the cookie.
>
>I looked at Apache::AuthCookie and it looks overly complex for my needs.

Something like the following?



package My::CookieAuth;

use strict;
use Apache::Constants qw(:common);
use CGI qw(:standard);
use CGI::Cookie ();

sub handler {
  my $r = shift;

  return DECLINED unless cookie(COOKIE_NAME);
  return OK;
}

__END__




In httpd.conf, you will need to set this as the PerlAuthenHandler 
for the protected files/directories and `require any' to get Apache 
to actually call it.  This is not the most efficient, but it could 
be a starting point for what you're looking for, if I understand 
what you're looking for.
-- 
James Smith <JG...@TAMU.Edu>, 979-862-3725
Texas A&M CIS Operating Systems Group, Unix

Re: simple cookie authorization?

Posted by Jason Bodnar <jb...@buzzard.kdi.com>.
On 21-Oct-2000 James G Smith wrote:
> Jason Bodnar <jb...@buzzard.kdi.com> wrote:
>>Is there a module for simple cookie authorization? I want to grant access if
>>the user has a cookie set. I don't care about the value of the cookie.
>>
>>I looked at Apache::AuthCookie and it looks overly complex for my needs.
> 
> Something like the following?

Exactly. I just didn't want to write it if somebody else had done it already ;-)


> package My::CookieAuth;
> 
> use strict;
> use Apache::Constants qw(:common);
> use CGI qw(:standard);
> use CGI::Cookie ();
> 
> sub handler {
>   my $r = shift;
> 
>   return DECLINED unless cookie(COOKIE_NAME);
>   return OK;
> }
> 
> __END__
> 
> 
> 
> 
> In httpd.conf, you will need to set this as the PerlAuthenHandler 
> for the protected files/directories and `require any' to get Apache 
> to actually call it.  This is not the most efficient, but it could 
> be a starting point for what you're looking for, if I understand 
> what you're looking for.
> -- 
> James Smith <JG...@TAMU.Edu>, 979-862-3725
> Texas A&M CIS Operating Systems Group, Unix

-- 
Jason Bodnar
jason@shakabuku.org