Dancer2-Plugin-Auth-Extensible

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

lib/Dancer2/Plugin/Auth/Extensible/Provider/Example.pm
lib/Dancer2/Plugin/Auth/Extensible/Provider/Config.pm
lib/Dancer2/Plugin/Auth/Extensible/Provider/Unix.pm
lib/Dancer2/Plugin/Auth/Extensible/Provider/Base.pm
lib/Dancer2/Plugin/Auth/Extensible/Role/Provider.pm
lib/Dancer2/Plugin/Auth/Extensible/Test.pm
lib/Dancer2/Plugin/Auth/Extensible/Test/App.pm
lib/Dancer2/Plugin/Auth/Extensible.pm
share/views/login.tt
share/views/login_denied.tt
share/views/transparent_login.tt
MANIFEST
MANIFEST.SKIP
bin/dancer2-generate-crypted-password
example/authextest.pl
example/config.yml
example/demo.t
ignore.txt
Makefile.PL
Changes
META.yml                                 Module YAML meta-data (added by MakeMaker)

lib/Dancer2/Plugin/Auth/Extensible.pm  view on Meta::CPAN

            $app->add_route(
                method => $method,
                regexp => qr!^$logout_page$!,
                code   => \&_logout_route,
            );
        }
    }

    if ( $plugin->login_without_redirect ) {

        # Add a post route so we can catch transparent login.
        # This is a little sucky but since no hooks are called before
        # route dispatch then adding this wildcard route now does at
        # least make sure it gets added before any routes that use this
        # plugin's route decorators are added.

        $plugin->app->add_route(
            method => 'post',
            regexp => qr/.*/,
            code   => sub {
                my $app     = shift;

lib/Dancer2/Plugin/Auth/Extensible.pm  view on Meta::CPAN


        # If this is the first attempt to reach a protected page and *not*
        # a failed passthrough login then we need to stash method and params.
        if ( !$request->var('login_failed') ) {
            $plugin->app->session->write(
                '__auth_extensible_method' => lc($request->method) );
            $plugin->app->session->write(
                '__auth_extensible_params' => \%{ $request->params } );
        }

        return $plugin->_render_login_page( 'transparent_login.tt', $tokens );
    }

    # old-fashioned redirect to login page with return_url set
    my $forward = $request->path;
    $forward .= "?".$request->query_string
        if $request->query_string;
    return $plugin->app->redirect(
        $request->uri_for(
            # Do not use request_uri, as it is the raw string sent by the
            # browser, not taking into account the application mount point.

t/login-without-redirect.t  view on Meta::CPAN

      POST "$url/protected_post",
      [
        __auth_extensible_username => 'dave',
        __auth_extensible_password => 'cider',
      ];
    $jar->add_cookie_header($req);
    my $res = $test->request( $req );
    $jar->extract_cookies($res);

    is $res->code, 401,
      "Now we post a bad password to the transparent login route and get 401";
    like $res->header('www-authenticate'), qr/Basic realm=/,
      "... and we have a WWW-Authenticate header with Basic realm";
    like $res->content, qr/You need to log in to continue/,
      "... and we can see a login form";
    like $res->content, qr/input.+name="__auth_extensible_username/,
      "... and we see __auth_extensible_username field";
    like $res->content, qr/This text is in the layout/,
      "... and the response is wrapped in the layout.";
}
{



( run in 0.350 second using v1.01-cache-2.11-cpan-0a6323c29d9 )