Authen-Simple-WebForm

 view release on metacpan or  search on metacpan

META.yml  view on Meta::CPAN

name:                Authen-Simple-WebForm
version:             0.02
abstract:            Simple authentication against existing web based forms.
license:             ~
author:              
    - Joshua I. Miller <unrtst@cpan.org>
generated_by:        ExtUtils::MakeMaker version 6.42
distribution_type:   module
requires:     
    Authen::Simple::Adapter:       0
    HTTP::Cookies:                 0
    LWP:                           0
    LWP::ConnCache:                0
    Test::More:                    0
    URI:                           0
meta-spec:
    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
    version: 1.3

Makefile.PL  view on Meta::CPAN

WriteMakefile(
    NAME                => 'Authen::Simple::WebForm',
    AUTHOR              => 'Joshua I. Miller <unrtst@cpan.org>',
    VERSION_FROM        => 'lib/Authen/Simple/WebForm.pm',
    ABSTRACT_FROM       => 'lib/Authen/Simple/WebForm.pm',
    PL_FILES            => {},
    PREREQ_PM => {
        'URI'                       => 0,
        'LWP'                       => 0,
        'LWP::ConnCache'            => 0,
        'HTTP::Cookies'             => 0,
        'Test::More'                => 0,
        'Authen::Simple::Adapter'   => 0,
    },
    dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
    clean               => { FILES => 'Authen-Simple-WebForm-*' },
);

README  view on Meta::CPAN


        Set to a unique string to expect in the resulting page when the
        login was successful.

        Be default, this is not turned on. If you do not set this, then as
        long as the server returns a successful status code (see
        HTTP::Status::is_success), then the user will be authenticated. Most
        form based login systems return a successful status code even when
        the login fails, so you'll probably want to set this.

        A notable exception is the use of something like Apache::AuthCookie,
        which will return a 403 Forbidden error code when authentication
        fails.

        Off by default.

    login_expect_cookie
        String or a compiled regex (eg. "qr/please\s+login/i").

        Similar to login_expect, but checks the cookies returned by the
        page. If you are also using "initial_url", please be aware that an

lib/Authen/Simple/WebForm.pm  view on Meta::CPAN


String or a compiled regex (eg. C<qr/login\s+successful/i>).

Set to a unique string to expect in the resulting page when the login was successful.

Be default, this is not turned on. If you do not set this, then as long as the
server returns a successful status code (see HTTP::Status::is_success), then
the user will be authenticated. Most form based login systems return a successful
status code even when the login fails, so you'll probably want to set this.

A notable exception is the use of something like L<Apache::AuthCookie>, which
will return a 403 Forbidden error code when authentication fails.

Off by default.


=item login_expect_cookie

String or a compiled regex (eg. C<qr/please\s+login/i>).

Similar to login_expect, but checks the cookies returned by the page. If you are also using "initial_url", please be aware that an cookies set by that page will also test true here (ie. this checks our cookie jar, not the content of the page). The co...

lib/Authen/Simple/WebForm.pm  view on Meta::CPAN

            {
                $search = sub { $found++ if $_[1] =~ /$expect/ && length($_[2]); };
            } else {
                $search = sub { $found++ if $_[1] eq $expect && length($_[2]); };
            }

            # search the cookie jar
            $ua->cookie_jar->scan($search);
            unless ($found)
            {
                $self->log->debug("Failed to authenticate user '$full_username'. Reason: Initial Cookie $expect was not found.")
                    if $self->log;
                return 0;
            }
        }
    }


    # build data to post
    my @data = (
        $self->username_field   => $full_username,

lib/Authen/Simple/WebForm.pm  view on Meta::CPAN

        {
            $search = sub { $found++ if $_[1] =~ /$expect/ && length($_[2]); };
        } else {
            $search = sub { $found++ if $_[1] eq $expect && length($_[2]); };
        }

        # search the cookie jar
        $ua->cookie_jar->scan($search);
        unless ($found)
        {
            $self->log->debug("Failed to authenticate user '$full_username'. Reason: Login Cookie $expect was not found.")
                if $self->log;
            return 0;
        }
    }

    $self->log->debug("Successfully authenticated user '$full_username'.") if $self->log;
    return 1;
}

=head1 TODO



( run in 0.826 second using v1.01-cache-2.11-cpan-e9199f4ba4c )