Catalyst-Plugin-Authentication-Store-HTTP

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


        # and in action
        sub login : Global {
            my ( $self, $c ) = @_;

            $c->login( $username, $password );
        }

DESCRIPTION
    This module is Catalyst authentication storage plugin that authenticates
    based on a URL HTTP HEAD fetch using the supplied credentials. If the
    fetch succeeds then the authentication succeeds.

    LWP::UserAgent is used to fetch the URL which requires authentication,
    so any authentication method supported by that module can be used.

    Remote authentication methods known to work are:-

    *   Basic

    *   Digest

README  view on Meta::CPAN

    This is re-implementation of
    Catalyst::Plugin::Authentication::Basic::Remote.

CONFIGURATION
    Configuration is done in the standard Catalyst fashion. All
    configuration keys are under "authentication/http".

    The supported keys are:-

    auth_url
        The URL that is fetched to demonstrate that the supplied credentials
        work. This can be any URL that LWP::UserAgent will support and that
        will support a "HEAD" method. This item must be supplied.

    keep_alive
        A boolean value that sets whether keep alive is used on the URL
        fetch. This must be set for NTLM authentication - and the *ntlm*
        configuration key forces it to be set.

    domain
        An optional domain value for authentication. If set the presented

lib/Catalyst/Plugin/Authentication/Store/HTTP.pm  view on Meta::CPAN

    sub login : Global {
        my ( $self, $c ) = @_;

        $c->login( $username, $password );
    }

=head1 DESCRIPTION

This module is Catalyst authentication storage plugin that
authenticates based on a URL HTTP HEAD fetch using the supplied
credentials.  If the fetch succeeds then the authentication succeeds.

L<LWP::UserAgent> is used to fetch the URL which requires authentication,
so any authentication method supported by that module can be used.

Remote authentication methods known to work are:-

=over 4

=item *

lib/Catalyst/Plugin/Authentication/Store/HTTP.pm  view on Meta::CPAN


Configuration is done in the standard Catalyst fashion.  All
configuration keys are under C<authentication/http>.

The supported keys are:-

=over 4

=item auth_url

The URL that is fetched to demonstrate that the supplied credentials
work.  This can be any URL that L<LWP::UserAgent> will support and
that will support a C<HEAD> method.  This item must be supplied.

=item keep_alive

A boolean value that sets whether keep alive is used on the URL
fetch. This must be set for NTLM authentication - and the I<ntlm>
configuration key forces it to be set.

=item domain

lib/Catalyst/Plugin/Authentication/Store/HTTP/User.pm  view on Meta::CPAN

=cut

sub check_password {
    my ($self, $password) = @_;

    my $ua =
      Catalyst::Plugin::Authentication::Store::HTTP::UserAgent->new(
        keep_alive => ($self->{keep_alive} ? 1 : 0));
    my $req = HTTP::Request->new(HEAD => $self->{auth_url});

    # set the credentials for the request.
    # if there is a domain set then prepend this onto the user id
    $ua->credentials(
        ($self->{domain} ? join("\\", $self->{domain}, $self->id) : $self->id),
        $password
    );

    my $res = $ua->request($req);

    $res->is_success;
}

=head2 for_session

lib/Catalyst/Plugin/Authentication/Store/HTTP/UserAgent.pm  view on Meta::CPAN

package Catalyst::Plugin::Authentication::Store::HTTP::UserAgent;
use strict;
use warnings;
use base qw/LWP::UserAgent/;

sub credentials {
    my ($self, $user, $pass) = @_;
    @{ $self->{credentials} } = ($user, $pass);
}

sub get_basic_credentials {
    my $self = shift;
    return @{ $self->{credentials} };
}

=head1 NAME

Catalyst::Plugin::Authentication::Store::HTTP::UserAgent - Wrapper for LWP::UserAgent

=head1 DESCRIPTION

A thin wrapper for L<LWP::UserAgent> to make basic auth simpler.

=head1 METHODS

=head2 credentials

now takes just a username and password

=head2 get_basic_credentials

Returns the set credentials, takes no options.

=head1 AUTHOR

Nigel Metheringham <nigelm@cpan.org> - integration into L<Catalyst::Plugin::Authentication::Store::HTTP>

Marcus Ramberg <mramberg@cpan.org - original code in L<Catalyst::Plugin::Authentication::Credential::HTTP::User>

=head1 LICENSE

This module is free software; you can redistribute it and/or modify it



( run in 0.278 second using v1.01-cache-2.11-cpan-4d50c553e7e )