X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAuthentication%2FCredential%2FOpenID.pm;h=6eb4d72820dae9648212032d6ead0a9c934b3730;hb=0638ecfb29f35dcb62c095307ad5966f299fa36e;hp=5f8a6efdfb3850c1bafd05f95996b69694ce61f6;hpb=4c4e7c7e91e6ae75d85d8ece8534629db2a66ba8;p=catagits%2FCatalyst-Authentication-Credential-OpenID.git diff --git a/lib/Catalyst/Authentication/Credential/OpenID.pm b/lib/Catalyst/Authentication/Credential/OpenID.pm index 5f8a6ef..6eb4d72 100644 --- a/lib/Catalyst/Authentication/Credential/OpenID.pm +++ b/lib/Catalyst/Authentication/Credential/OpenID.pm @@ -3,7 +3,16 @@ use strict; use warnings; use base "Class::Accessor::Fast"; -__PACKAGE__->mk_accessors(qw/ _config realm debug secret /); +__PACKAGE__->mk_accessors(qw/ + realm debug secret + openid_field + consumer_secret + ua_class + ua_args + extension_args + errors_are_fatal + extensions +/); our $VERSION = "0.16"; @@ -12,18 +21,16 @@ use Catalyst::Exception (); sub new { my ( $class, $config, $c, $realm ) = @_; - my $self = { _config => { %{ $config }, - %{ $realm->{config} } - } + my $self = { + %{ $config }, + %{ $realm->{config} } }; bless $self, $class; # 2.0 spec says "SHOULD" be named "openid_identifier." - $self->_config->{openid_field} ||= "openid_identifier"; - - $self->debug( $self->_config->{debug} ); + $self->{openid_field} ||= "openid_identifier"; - my $secret = $self->_config->{consumer_secret} ||= join("+", + my $secret = $self->{consumer_secret} ||= join("+", __PACKAGE__, $VERSION, sort keys %{ $c->config } @@ -32,13 +39,13 @@ sub new { $secret = substr($secret,0,255) if length $secret > 255; $self->secret($secret); # If user has no preference we prefer L::PA b/c it can prevent DoS attacks. - $self->_config->{ua_class} ||= eval "use LWPx::ParanoidAgent" ? + my $ua_class = $self->{ua_class} ||= eval "use LWPx::ParanoidAgent" ? "LWPx::ParanoidAgent" : "LWP::UserAgent"; - my $agent_class = $self->_config->{ua_class}; + my $agent_class = $self->ua_class; eval "require $agent_class" or Catalyst::Exception->throw("Could not 'require' user agent class " . - $self->_config->{ua_class}); + $self->ua_class); $c->log->debug("Setting consumer secret: " . $secret) if $self->debug; @@ -50,7 +57,7 @@ sub authenticate { $c->log->debug("authenticate() called from " . $c->request->uri) if $self->debug; - my $field = $self->{_config}->{openid_field}; + my $field = $self->openid_field; my $claimed_uri = $authinfo->{ $field }; @@ -60,19 +67,20 @@ sub authenticate { my $csr = Net::OpenID::Consumer->new( - ua => $self->_config->{ua_class}->new(%{$self->_config->{ua_args} || {}}), + ua => $self->ua_class->new(%{$self->ua_args || {}}), args => $c->req->params, consumer_secret => $self->secret, ); - if ( $self->_config->{extension_args} and $self->debug ) + if ( $self->extension_args and $self->debug ) { - $c->log->info("The configuration key 'extension_args' is deprecated; use 'extensions'"); + # FIXME - Only on startup, remove extension_args accessor + $c->log->warn("The configuration key 'extension_args' is deprecated; use 'extensions'"); } - my @extensions = $self->_config->{extensions} ? - @{ $self->_config->{extensions} } : $self->_config->{extension_args} ? - @{ $self->_config->{extension_args} } : (); + my @extensions = $self->extensions ? + @{ $self->extensions } : $self->extension_args ? + @{ $self->extension_args } : (); if ( $claimed_uri ) { @@ -81,7 +89,7 @@ sub authenticate { my $identity = $csr->claimed_identity($claimed_uri); unless ( $identity ) { - if ( $self->_config->{errors_are_fatal} ) + if ( $self->errors_are_fatal ) { Catalyst::Exception->throw($csr->err); } @@ -140,7 +148,7 @@ sub authenticate { } else { - $self->_config->{errors_are_fatal} ? + $self->errors_are_fatal ? Catalyst::Exception->throw("Error validating identity: " . $csr->err) : $c->log->error( $csr->err);