Skip Menu |

This queue is for tickets about the Catalyst-Authentication-Credential-OpenID CPAN distribution.

Report information
The Basics
Id: 56332
Status: resolved
Priority: 0/
Queue: Catalyst-Authentication-Credential-OpenID

People
Owner: Nobody in particular
Requestors: TREVELYAN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Handle more then one extension (patch)
Hi, The current implementation (0.16) fell over if you define more then one extension. However I need this since google uses ax, but others use sreg. So I made the following changes: --- /tmp/OpenID.pm 2010-04-06 21:59:41.000000000 +0200 +++ /home/thorbenj/local/lib/perl5/Catalyst/Authentication/Credential/OpenID. @@ -67,18 +67,16 @@ consumer_secret => $self->secret, ); - if ( $self->_config->{extension_args} and $self->debug ) + if ( $self->_config->{extension_args} ) { - $c->log->info("The configuration key 'extension_args' is deprecated; use 'extensions'"); + $c->log->warn("The configuration key 'extension_args' is ignored!"); } - my @extensions = $self->_config->{extensions} ? - @{ $self->_config->{extensions} } : $self->_config- - @{ $self->_config->{extension_args} } : (); + my %extensions = $self->_config->{extensions} ? %{ $self->_config- if ( $claimed_uri ) { - my $current = $c->uri_for($c->req->uri->path); # clear query/fragment... + my $current = $c->uri_for('/'.$c->req->path); # clear query/fragment... my $identity = $csr->claimed_identity($claimed_uri); unless ( $identity ) @@ -94,8 +92,10 @@ } } - $identity->set_extension_args(@extensions) - if @extensions; + #Can only pass one pair at a time. + while (my (@ext) = each %extensions) { + $identity->set_extension_args(@ext) + } my $check_url = $identity->check_url( return_to => $current . '?openid-check=1', @@ -122,8 +122,7 @@ my $user = +{ map { $_ => scalar $identity->$_ } qw( url display rss atom foaf declared_rss declared_atom declared_foaf foafmaker ) }; # Dude, I did not design the array as hash spec. Don't curse me [apv]. - my %flat = @extensions; - for my $key ( keys %flat ) + for my $key ( keys %extensions ) { $user->{extensions}->{$key} = $identity- } My config looks like this: 'Plugin::Authentication' => { openid => { credential => { class => 'OpenID', ua_class => 'LWP::UserAgent', extensions => { 'http://openid.net/extensions/sreg/1.1' => { required => 'nickname,email,fullname', optional => 'timezone,language,dob,country,gender' }, 'http://openid.net/srv/ax/1.0' => { mode => 'fetch_request', 'type.nickname' => 'http://axschema.org/namePerson/friendly', 'type.email' => 'http://axschema.org/contact/email', 'type.fullname' => 'http://axschema.org/namePerson', 'type.firstname' => 'http://axschema.org/namePerson/first', 'type.lastname' => 'http://axschema.org/namePerson/last', 'type.dob' => 'http://axschema.org/birthDate', 'type.gender' => 'http://axschema.org/person/gender', 'type.country' => 'http://axschema.org/contact/country/home', 'type.language' => 'http://axschema.org/pref/language', 'type.timezone' => 'http://axschema.org/pref/timezone', required => 'nickname,fullname,email,firstname,lastname', if_available => 'dob,gender,country,language,timezone', }, }, }, }, default_realm => 'openid', }, It works with Google and myopenid. Regards, Thorben
From: ashley [...] cpan.org
This and the other are in 0.16_01. Please let me know if they work as expected or if I've missed something. Thanks! -Ashley On Tue Apr 06 16:03:57 2010, TREVELYAN wrote: Show quoted text
> Hi, > > The current implementation (0.16) fell over if you define more then > one > extension. However I need this since google uses ax, but others use > sreg. > > So I made the following changes: > > --- /tmp/OpenID.pm 2010-04-06 21:59:41.000000000 +0200 > +++ > /home/thorbenj/local/lib/perl5/Catalyst/Authentication/Credential/OpenID. > @@ -67,18 +67,16 @@ > consumer_secret => $self->secret, > ); > > - if ( $self->_config->{extension_args} and $self->debug ) > + if ( $self->_config->{extension_args} ) > { > - $c->log->info("The configuration key 'extension_args' is > deprecated; use 'extensions'"); > + $c->log->warn("The configuration key 'extension_args' is > ignored!"); > } > > - my @extensions = $self->_config->{extensions} ? > - @{ $self->_config->{extensions} } : $self->_config- > - @{ $self->_config->{extension_args} } : (); > + my %extensions = $self->_config->{extensions} ? %{ $self-
> >_config-
> > if ( $claimed_uri ) > { > - my $current = $c->uri_for($c->req->uri->path); # clear > query/fragment... > + my $current = $c->uri_for('/'.$c->req->path); # clear > query/fragment... > > my $identity = $csr->claimed_identity($claimed_uri); > unless ( $identity ) > @@ -94,8 +92,10 @@ > } > } > > - $identity->set_extension_args(@extensions) > - if @extensions; > + #Can only pass one pair at a time. > + while (my (@ext) = each %extensions) { > + $identity->set_extension_args(@ext) > + } > > my $check_url = $identity->check_url( > return_to => $current . '?openid-check=1', > @@ -122,8 +122,7 @@ > my $user = +{ map { $_ => scalar $identity->$_ } > qw( url display rss atom foaf declared_rss > declared_atom > declared_foaf foafmaker ) }; > # Dude, I did not design the array as hash spec. Don't > curse > me [apv]. > - my %flat = @extensions; > - for my $key ( keys %flat ) > + for my $key ( keys %extensions ) > { > $user->{extensions}->{$key} = $identity- > } > > > My config looks like this: > > 'Plugin::Authentication' => { > openid => { > credential => { > class => 'OpenID', > ua_class => 'LWP::UserAgent', > extensions => { > > 'http://openid.net/extensions/sreg/1.1' => { > required => > 'nickname,email,fullname', > optional => > 'timezone,language,dob,country,gender' > }, > 'http://openid.net/srv/ax/1.0' => > { > mode => 'fetch_request', > 'type.nickname' => > 'http://axschema.org/namePerson/friendly', > 'type.email' => > 'http://axschema.org/contact/email', > 'type.fullname' => > 'http://axschema.org/namePerson', > 'type.firstname' => > 'http://axschema.org/namePerson/first', > 'type.lastname' => > 'http://axschema.org/namePerson/last', > 'type.dob' => > 'http://axschema.org/birthDate', > 'type.gender' => > 'http://axschema.org/person/gender', > 'type.country' => > 'http://axschema.org/contact/country/home', > 'type.language' => > 'http://axschema.org/pref/language', > 'type.timezone' => > 'http://axschema.org/pref/timezone', > required => > 'nickname,fullname,email,firstname,lastname', > if_available => > 'dob,gender,country,language,timezone', > }, > }, > }, > }, > default_realm => 'openid', > }, > > > It works with Google and myopenid. > > Regards, > > Thorben