Catalyst-Authentication-Credential-RemoteHTTP
view release on metacpan or search on metacpan
class
The classname used for Credential. This is part of
Catalyst::Plugin::Authentication and is the method by which
Catalyst::Authentication::Credential::RemoteHTTP is loaded as the
credential validator. For this module to be used, this must be set
to 'RemoteHTTP'.
url The URL that is used to authenticate the user. The module attempts
to fetch this URL using a HEAD request (to prevent dragging a large
page across the network) with the credentials given. If this fails
then the authentication fails. If no URL is supplied in the config,
then an exception is thrown on startup.
username_field
The field in the authentication hash that contains the username.
This may vary, but is most likely 'username'. In fact, this is so
common that if this is left out of the config, it defaults to
'username'.
password_field
lib/Catalyst/Authentication/Credential/RemoteHTTP.pm view on Meta::CPAN
unless ( $self->defer_find_user );
if ( ref($user_obj) || $self->defer_find_user ) {
my $ua =
Catalyst::Authentication::Credential::RemoteHTTP::UserAgent->new(
keep_alive => $self->http_keep_alive ? 1 : 0 );
# add prefix/suffix to user data to make auth_user, get password
my $auth_user = sprintf( '%s%s%s', $self->user_prefix, $username, $self->user_suffix );
my $password = $authinfo->{ $self->password_field };
$ua->set_credentials( $auth_user, $password );
# do the request
my $res = $ua->head( $self->url );
# did it succeed
if ( $res->is_success ) {
# TODO: should we check here that it was actually authenticated?
# this could be done by ensuring there is a request chain...
$c->log->debug( "remote http auth succeeded for user " . $auth_user )
lib/Catalyst/Authentication/Credential/RemoteHTTP.pm view on Meta::CPAN
The classname used for Credential. This is part of
L<Catalyst::Plugin::Authentication> and is the method by which
Catalyst::Authentication::Credential::RemoteHTTP is loaded as the
credential validator. For this module to be used, this must be set to
'RemoteHTTP'.
=item url
The URL that is used to authenticate the user. The module attempts
to fetch this URL using a HEAD request (to prevent dragging a large
page across the network) with the credentials given. If this fails
then the authentication fails. If no URL is supplied in the config,
then an exception is thrown on startup.
=item username_field
The field in the authentication hash that contains the username.
This may vary, but is most likely 'username'. In fact, this is so
common that if this is left out of the config, it defaults to
'username'.
lib/Catalyst/Authentication/Credential/RemoteHTTP/UserAgent.pm view on Meta::CPAN
# ABSTRACT: Wrapper for LWP::UserAgent
use strict;
use warnings;
use base qw/LWP::UserAgent/;
our $VERSION = '0.05'; # VERSION
our $AUTHORITY = 'cpan:NIGELM'; # AUTHORITY
sub set_credentials {
my ($self, $user, $pass) = @_;
@{ $self->{credentials} } = ($user, $pass);
}
sub get_basic_credentials {
my $self = shift;
return @{ $self->{credentials} };
}
1;
__END__
=pod
=for stopwords ACKNOWLEDGEMENTS Marcus Ramberg
lib/Catalyst/Authentication/Credential/RemoteHTTP/UserAgent.pm view on Meta::CPAN
=head1 VERSION
version 0.05
=head1 DESCRIPTION
A thin wrapper for L<LWP::UserAgent> to make basic authentication simpler.
=head1 METHODS
=head2 set_credentials
now takes just a username and password
=head2 get_basic_credentials
Returns the set credentials, takes no options.
=head1 ACKNOWLEDGEMENTS
Marcus Ramberg <mramberg@cpan.org - original code in L<Catalyst::Plugin::Authentication::Credential::HTTP::User>
=head1 INSTALLATION
See perlmodinstall for information and options on installing Perl modules.
=head1 BUGS AND LIMITATIONS
( run in 0.237 second using v1.01-cache-2.11-cpan-a5abf4f5562 )