[Catalyst] Using Progressive realms when username and password
fields are all different
Dave Howorth
dhoworth at mrc-lmb.cam.ac.uk
Fri Jun 29 10:34:23 GMT 2012
Will Crawford wrote:
> On 28 June 2012 23:12, Gavin Henry <gavin.henry at gmail.com> wrote:
> ...
>> Thanks Tim. Yes, I know that but then the other two realms will fail
>> and that's the point of progressive. I want to call one ->authenticate
>> which tries all the realms I've defined in progressive_oauth.
>
> Regrettably, the docs for the Password realm saith:
>
> NOTE If the password_field is something other than 'password', you
> must be sure to use that same field name when calling
> $c->authenticate().
>
> I'd call that a bug, personally - it certainly isn't intuitive that
> you can specify the field to use, but then have to remember it in all
> your calls to authenticate().
>
> Not much can be done about that, though. Maybe someone can produce an adaptor?
Does something like this fix the problem?
--- Password.pm 2012-06-29 11:23:51.000000000 +0100
+++ Password-new.pm 2012-06-29 11:33:40.000000000 +0100
@@ -34,6 +34,14 @@
sub authenticate {
my ( $self, $c, $realm, $authinfo ) = @_;
+ my $password_field = $self->_config->{'password_field'};
+ if ($password_field ne 'password'
+ and defined $authinfo->{password}) {
+ $authinfo = {%{$authinfo}};
+ $authinfo->{$password_field} = $authinfo->{password};
+ delete $authinfo->{password};
+ }
+
## because passwords may be in a hashed format, we have to make
sure that we remove the
## password_field before we pass it to the user routine, as some
auth modules use
## all data passed to them to find a matching user...
More information about the Catalyst
mailing list