Hi,

If nobody has any idea, perhaps somebody knows just this, that would help me finding it out:
How do I find out where Dancer2 gets the user you get when using Digest Authentication in:

$dsl->app->request->user;


I expected this would be via the environment hash, %ENV, but it seems not. Because I can set ${'REMOTE_USER'} in a plack test, get it in my Dancer2 app, but I not get it via $dsl->app->request->user;

Kind regards,
Arjan.

On 09/03/2015 07:51 PM, Arjan Widlak wrote:
Hi,

Is it possible to test Digest Authentication with Plack::Test without starting a live server?

With a live server I can do this:

    my $browser = LWP::UserAgent->new();
    $req = HTTP::Request->new( GET => 'http://localhost:5000/' );
    $browser->credentials(
        "localhost:5000",
        "ZZZZZZ",
        'arjan@xxxxxx.nl' => 'xxxxxx'
    );
    $res = $browser->request( $req );
    ok( $res->status_line eq '200 OK', 'success with login with credentials' );

And in my Dancer2 app I get:

get '/' => sub {
    my $dsl     = shift;
    my $user    = $dsl->app->request->user;

Is it possible to do something like:

my $test = Plack::Test->create($app);

my $req = GET '/mYtQ2EeQthcclMhsqDZTbVcggwX9kJDo';
$req->header( "Accept"           => "application/json" );
$req->header( "Host"             => "localhost" );
$req->header( "Authorization"    => 'Digest username="arjan@xxxxxx.nl",
                                     realm="ZZZZZZ",
                                     nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
                                     uri="/",
                                     qop=auth,
                                     nc=00000001,
                                     cnonce="0a4f113b",
                                     response="6629fae49393a05397450978507c4ef1",
                                     opaque="5ccc069c403ebaf9f0171e9517f40e41"');
my $res = $test->request( $req );

And get the user in Dancer2 in the same way:

get '/' => sub {
    my $dsl     = shift;
    my $user    = $dsl->app->request->user;

Where does Dancer2 get the user that is returned with $dsl->app->request->user? I had a hard time finding this in Dancer2::Core::Request.pm, where it's in the documentation.

Kind regards,
Arjan.


_______________________________________________
dancer-users mailing list
dancer-users@dancer.pm
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users


-- 
Met vriendelijke groet,
Arjan Widlak

Bezoek onze site op:
http://www.unitedknowledge.nl

De rijkshuisstijl, ook voor tablet en iPhone:
http://www.rijkshuisstijl.unitedknowledge.nl/

United Knowledge, inhoud en techniek 
Bilderdijkstraat 79N
1053 KM Amsterdam
T +31 (0)20 737 1851
F +31 (0)84 877 0399
bureau@unitedknowledge.nl
http://www.unitedknowledge.nl

M +31 (0)6 2427 1444
E arjan@unitedknowledge.nl

We use WebGUI, the Open Source CMS
http://www.webgui.org/