X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAuthentication%2FCredential%2FRemote.pm;h=b4266c6470854f15ceb4433a59e8db9e80811ab7;hb=7289cea01f93cd01e7dd4fa6b2d281fab878d98a;hp=f39602fa8f968b492d7645950fd16a2c376b1b21;hpb=9172af6de8c74c0e87583d0f217e07358e4f38c9;p=catagits%2FCatalyst-Plugin-Authentication.git diff --git a/lib/Catalyst/Authentication/Credential/Remote.pm b/lib/Catalyst/Authentication/Credential/Remote.pm index f39602f..b4266c6 100644 --- a/lib/Catalyst/Authentication/Credential/Remote.pm +++ b/lib/Catalyst/Authentication/Credential/Remote.pm @@ -6,7 +6,8 @@ use warnings; 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 @@ sub new { 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 @@ sub new { } $self->source($config->{source} || 'REMOTE_USER'); $self->realm($realm); + $self->username_field($config->{username_field} || 'username'); return $self; } @@ -103,7 +105,7 @@ sub authenticate { } } - $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 @@ Substring is always taken as '$1' regexp substring. If WEBUSER does not 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 - default is I + +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 key. + =head1 METHODS =head2 new ( $config, $app, $realm )