Catalyst-Authentication-Credential-OpenID
view release on metacpan or search on metacpan
lib/Catalyst/Authentication/Credential/OpenID.pm view on Meta::CPAN
{
return;
}
elsif ( my $identity = $csr->verified_identity )
{
# This is where we ought to build an OpenID user and verify against the spec.
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].
for my $key ( keys %extensions )
{
my $vals = $identity->signed_extension_fields($key);
$user->{extensions}->{$key} = $vals;
if ( $self->flatten_extensions_into_user )
{
$user->{$_} = $vals->{$_} for keys %{$vals};
}
}
my $user_obj = $realm->find_user($user, $c);
if ( ref $user_obj )
{
return $user_obj;
}
else
{
$c->log->debug("Verified OpenID identity failed to load with find_user; bad user_class? Try 'Null.'") if $self->debug;
return;
}
}
else
{
$self->errors_are_fatal ?
Catalyst::Exception->throw("Error validating identity: " . $csr->err)
:
$c->log->error( $csr->err);
}
}
return;
}
1;
__END__
=head1 NAME
Catalyst::Authentication::Credential::OpenID - OpenID credential for Catalyst::Plugin::Authentication framework.
=head1 BACKWARDS COMPATIBILITY CHANGES
=head2 EXTENSION_ARGS v EXTENSIONS
B<NB>: The extensions were previously configured under the key C<extension_args>. They are now configured under C<extensions>. C<extension_args> is no longer honored.
As previously noted, L</EXTENSIONS TO OPENID>, I have not tested the extensions. I would be grateful for any feedback or, better, tests.
=head2 FATALS
The problems encountered by failed OpenID operations have always been fatals in the past. This is unexpected behavior for most users as it differs from other credentials. Authentication errors here are no longer fatal. Debug/error output is improved ...
=head1 SYNOPSIS
In MyApp.pm-
use Catalyst qw/
Authentication
Session
Session::Store::FastMmap
Session::State::Cookie
/;
Somewhere in myapp.conf-
<Plugin::Authentication>
default_realm openid
<realms>
<openid>
<credential>
class OpenID
ua_class LWP::UserAgent
</credential>
</openid>
</realms>
</Plugin::Authentication>
Or in your myapp.yml if you're using L<YAML> instead-
Plugin::Authentication:
default_realm: openid
realms:
openid:
credential:
class: OpenID
ua_class: LWP::UserAgent
In a controller, perhaps C<Root::openid>-
sub openid : Local {
my($self, $c) = @_;
if ( $c->authenticate() )
{
$c->flash(message => "You signed in with OpenID!");
$c->res->redirect( $c->uri_for('/') );
}
else
{
# Present OpenID form.
}
}
And a L<Template> to match in C<openid.tt>-
<form action="[% c.uri_for('/openid') %]" method="GET" name="openid">
<input type="text" name="openid_identifier" class="openid" />
<input type="submit" value="Sign in with OpenID" />
</form>
=head1 DESCRIPTION
( run in 2.312 seconds using v1.01-cache-2.11-cpan-140bd7fdf52 )