[Catalyst-commits] r10588 - in
Catalyst-Plugin-Authentication/0.10000/trunk: .
lib/Catalyst/Authentication/Credential lib/Catalyst/Plugin t t/lib
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Fri Jun 19 15:14:16 GMT 2009
Author: t0m
Date: 2009-06-19 15:14:16 +0000 (Fri, 19 Jun 2009)
New Revision: 10588
Modified:
Catalyst-Plugin-Authentication/0.10000/trunk/Changes
Catalyst-Plugin-Authentication/0.10000/trunk/lib/Catalyst/Authentication/Credential/Remote.pm
Catalyst-Plugin-Authentication/0.10000/trunk/lib/Catalyst/Plugin/Authentication.pm
Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp2.pm
Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_remote2.t
Log:
Make Credential::Remote have a username_field config option
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/Changes
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/Changes 2009-06-18 22:05:24 UTC (rev 10587)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/Changes 2009-06-19 15:14:16 UTC (rev 10588)
@@ -1,5 +1,7 @@
Revision history for Perl extension Catalyst::Plugin::Authentication
+ - Add a username_field config item to ::Credential::Remote
+ (Nigel Metheringham)
- Die with a useful error message if we are about to try to restore
a user from a realm which does not exist. (t0m)
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/lib/Catalyst/Authentication/Credential/Remote.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/lib/Catalyst/Authentication/Credential/Remote.pm 2009-06-18 22:05:24 UTC (rev 10587)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/lib/Catalyst/Authentication/Credential/Remote.pm 2009-06-19 15:14:16 UTC (rev 10588)
@@ -6,7 +6,8 @@
use base 'Class::Accessor::Fast';
BEGIN {
- __PACKAGE__->mk_accessors(qw/allow_re deny_re cutname_re source realm/);
+ __PACKAGE__->mk_accessors(
+ qw/allow_re deny_re cutname_re source realm username_field/);
}
sub new {
@@ -14,7 +15,7 @@
my $self = { };
bless $self, $class;
-
+
# we are gonna compile regular expresions defined in config parameters
# and explicitly throw an exception saying what parameter was invalid
if (defined($config->{allow_regexp}) && ($config->{allow_regexp} ne "")) {
@@ -34,6 +35,7 @@
}
$self->source($config->{source} || 'REMOTE_USER');
$self->realm($realm);
+ $self->username_field($config->{username_field} || 'username');
return $self;
}
@@ -103,7 +105,7 @@
}
}
- $authinfo->{id} = $authinfo->{username} = $usr;
+ $authinfo->{id} = $authinfo->{ $self->username_field } = $usr;
$authinfo->{remote_user} = $remuser; # just to keep the original value
my $user_obj = $realm->find_user( $authinfo, $c );
return ref($user_obj) ? $user_obj : undef;
@@ -262,6 +264,14 @@
match cutname_regexp at all or if '$1' regexp substring is empty we pass the
original WEBUSER value (without cutting) to Catalyst application.
+=head2 username_field
+
+This config item is B<OPTIONAL> - default is I<username>
+
+The key name in the authinfo hash that the user's username is mapped into.
+This is useful for using a store which requires a specific unusual field name
+for the username. The username is additionally mapped onto the I<id> key.
+
=head1 METHODS
=head2 new ( $config, $app, $realm )
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/lib/Catalyst/Plugin/Authentication.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/lib/Catalyst/Plugin/Authentication.pm 2009-06-18 22:05:24 UTC (rev 10587)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/lib/Catalyst/Plugin/Authentication.pm 2009-06-19 15:14:16 UTC (rev 10588)
@@ -1113,8 +1113,12 @@
David Kamholz
-Tomas Doran (t0m), C<bobtfish at bobtfish.net>
+Tomas Doran (t0m), C<bobtfish at bobtfish.net>
+kmx
+
+Nigel Metheringham
+
=head1 COPYRIGHT & LICENSE
Copyright (c) 2005 the aforementioned authors. All rights
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp2.pm
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp2.pm 2009-06-18 22:05:24 UTC (rev 10587)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/lib/RemoteTestApp2.pm 2009-06-19 15:14:16 UTC (rev 10588)
@@ -17,6 +17,7 @@
deny_regexp=> 'denied',
cutname_regexp=> 'CN=(.*)/OU=Test',
source => 'SSL_CLIENT_S_DN',
+ username_field => 'my_user_name',
},
store => {
class => 'Null',
@@ -29,7 +30,10 @@
sub default : Local {
my ( $self, $c ) = @_;
if ($c->authenticate()) {
- $c->res->body('User:' . $c->user->{id});
+ $c->res->body( 'User:'
+ . $c->user->{id} . "\n"
+ . 'my_user_name:'
+ . $c->user->{my_user_name} );
}
else {
$c->res->body('FAIL');
Modified: Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_remote2.t
===================================================================
--- Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_remote2.t 2009-06-18 22:05:24 UTC (rev 10587)
+++ Catalyst-Plugin-Authentication/0.10000/trunk/t/live_app_remote2.t 2009-06-19 15:14:16 UTC (rev 10588)
@@ -16,4 +16,5 @@
$RemoteTestEngine::SSL_CLIENT_S_DN = 'CN=namexyz/OU=Test/C=Company';
ok( request('/')->is_success, 'testing "source" + "cutname" 1' );
-is( request('/')->content, 'User:namexyz', 'testing "source" + "cutname" 2' );
+is( request('/')->content, "User:namexyz\nmy_user_name:namexyz",
+ 'testing "source" + "cutname" 2' );
More information about the Catalyst-commits
mailing list