[Catalyst-commits] r11543 -
Catalyst-Authentication-Credential-OpenID/trunk/lib/Catalyst/Authentication/Credential
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Fri Oct 16 08:32:43 GMT 2009
Author: t0m
Date: 2009-10-16 08:32:42 +0000 (Fri, 16 Oct 2009)
New Revision: 11543
Modified:
Catalyst-Authentication-Credential-OpenID/trunk/lib/Catalyst/Authentication/Credential/OpenID.pm
Log:
Remove _config of evil
Modified: Catalyst-Authentication-Credential-OpenID/trunk/lib/Catalyst/Authentication/Credential/OpenID.pm
===================================================================
--- Catalyst-Authentication-Credential-OpenID/trunk/lib/Catalyst/Authentication/Credential/OpenID.pm 2009-10-16 08:21:45 UTC (rev 11542)
+++ Catalyst-Authentication-Credential-OpenID/trunk/lib/Catalyst/Authentication/Credential/OpenID.pm 2009-10-16 08:32:42 UTC (rev 11543)
@@ -3,7 +3,16 @@
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 @@
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->{openid_field} ||= "openid_identifier";
- $self->debug( $self->_config->{debug} );
-
- my $secret = $self->_config->{consumer_secret} ||= join("+",
+ my $secret = $self->{consumer_secret} ||= join("+",
__PACKAGE__,
$VERSION,
sort keys %{ $c->config }
@@ -32,13 +39,13 @@
$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 @@
$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 @@
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 @@
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 @@
}
else
{
- $self->_config->{errors_are_fatal} ?
+ $self->errors_are_fatal ?
Catalyst::Exception->throw("Error validating identity: " . $csr->err)
:
$c->log->error( $csr->err);
More information about the Catalyst-commits
mailing list