Catalyst-Authentication-Credential-Crowd
view release on metacpan or search on metacpan
lib/Catalyst/Authentication/Credential/Crowd.pm view on Meta::CPAN
my ($self, $c, $realm, $authinfo) = @_;
my $response = $self->_crowd_authen( $authinfo->{username}, $authinfo->{password} );
if ( $response->is_success ){
my $user = $realm->find_user( { username => $authinfo->{username} }, $c );
if ( $user ) {
return $user;
} else {
$c->stash( auth_error_msg => 'Authenticated user, but could not locate in store!' );
return;
}
} elsif ($response->code == 403 && $response->decoded_content =~ m|<h1>HTTP Status 403 - (.*?)</h1>|i) {
# indicates a tomcat problem, should probably do something else here?
$c->log->warn("Problem comunicating with crowd server: " . $response->code );
$c->stash( auth_error_msg => 'tomcat problem: ' . $1 );
} else {
$c->stash( auth_error_msg => $response->decoded_content );
}
return;
}
sub _crowd_authen {
my ( $self, $username, $password ) = @_;
my $ua = LWP::UserAgent->new;
my $uri = $self->authen_url."?username=$username";
my $json_hash = { value => $password };
( run in 0.227 second using v1.01-cache-2.11-cpan-26ccb49234f )