Subject: | Proposal Catalyst::Authentication::Credential::Remote |
Date: | Mon, 25 May 2009 16:16:19 +0200 |
To: | bug-Catalyst-Plugin-Authentication [...] rt.cpan.org |
From: | kmx <kmx [...] volny.cz> |
package Catalyst::Authentication::Credential::Remote;
use strict;
use warnings;
use base 'Class::Accessor::Fast';
BEGIN {
__PACKAGE__->mk_accessors(qw/_config realm/);
}
sub new {
my ( $class, $config, $app, $realm ) = @_;
my $self = { _config => $config };
bless $self, $class;
$self->realm($realm);
return $self;
}
sub authenticate {
my ( $self, $c, $realm, $authinfo ) = @_;
my $allow_re = $self->_config->{'allow_regexp'};
my $deny_re = $self->_config->{'deny_regexp'};
my $remuser = $c->req->remote_user; # user authenticated by WWW server
my $authuser = $authinfo->{username};
return unless defined($remuser);
return if (defined($authuser) && ($authuser ne $remuser) );
return if (defined($deny_re) && ($remuser =~ /$deny_re/) );
return if (defined($allow_re) && ($remuser !~ /$allow_re/));
$authinfo->{id} = $authinfo->{username} = $remuser;
my $user_obj = $realm->find_user( $authinfo, $c );
return ref($user_obj) ? $user_obj : undef;
}
1;
Hi,
I have prepared a draft of credential module that works like "web server
does auth for me, I trust it and wanna use it in my CatApp"
It uses $c->remote_user variable that is currently available just in Cat
trunk revision (probably will be part of 5.80005).
I you find it useful I am ready to finalize it and write a doc and would
appreciate if you could include it into Catalyst-Plugin-Authentication
(yes, I am lazy to start a new separate module).
Of course any comments are welcome (to the overall idea as well as the
proposed implementation).
--
kmx