<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi,<br>
<br>
If nobody has any idea, perhaps somebody knows just this, that
would help me finding it out:<br>
How do I find out where Dancer2 gets the user you get when using
Digest Authentication in:<br>
<code><br>
$dsl->app->request->user;</code><br>
<br>
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 <code>$dsl->app->request->user;</code><br>
<br>
Kind regards,<br>
Arjan.<br>
<br>
On 09/03/2015 07:51 PM, Arjan Widlak wrote:<br>
</div>
<blockquote cite="mid:55E888AA.8090606@unitedknowledge.nl"
type="cite">
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
Hi,<br>
<br>
Is it possible to test Digest Authentication with Plack::Test
without starting a live server?<br>
<br>
With a live server I can do this:<br>
<br>
<code> my $browser = LWP::UserAgent->new();</code><code><br>
</code><code> $req = HTTP::Request->new( GET => '<a
moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://localhost:5000/"><a class="moz-txt-link-freetext" href="http://localhost:5000/">http://localhost:5000/</a></a>' );</code><code><br>
</code><code> $browser->credentials(</code><code><br>
</code><code> "localhost:5000",</code><code><br>
</code><code> "ZZZZZZ",</code><code><br>
</code><code> '<a moz-do-not-send="true"
class="moz-txt-link-abbreviated" href="mailto:arjan@xxxxxx.nl">arjan@xxxxxx.nl</a>'
=> 'xxxxxx'</code><code><br>
</code><code> );</code><code></code><code><br>
</code><code> $res = $browser->request( $req );</code><code><br>
</code><code> ok( $res->status_line eq '200 OK', 'success
with login with credentials' );</code><br>
<br>
And in my Dancer2 app I get:<br>
<br>
<code>get '/' => sub {</code><code><br>
</code><code> my $dsl = shift;</code><code><br>
</code><code> my $user = $dsl->app->request->user;</code><br>
<br>
Is it possible to do something like:<br>
<br>
my $test = Plack::Test->create($app);<br>
<br>
<code>my $req = GET '/mYtQ2EeQthcclMhsqDZTbVcggwX9kJDo';</code><code><br>
</code><code>$req->header( "Accept" =>
"application/json" );</code><code><br>
</code><code>$req->header( "Host" => "localhost"
);</code><code><br>
</code><code>$req->header( "Authorization" => 'Digest
username=<a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:arjan@xxxxxx.nl">"arjan@xxxxxx.nl"</a>,</code><code><br>
</code><code> realm="ZZZZZZ",</code><code><br>
</code><code>
nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",</code><code><br>
</code><code> uri="/",</code><code><br>
</code><code> qop=auth,</code><code><br>
</code><code> nc=00000001,</code><code><br>
</code><code>
cnonce="0a4f113b",</code><code><br>
</code><code>
response="6629fae49393a05397450978507c4ef1",</code><code><br>
</code><code>
opaque="5ccc069c403ebaf9f0171e9517f40e41"');</code><code><br>
</code><code>my $res = $test->request( $req );</code><br>
<br>
And get the user in Dancer2 in the same way:<br>
<br>
<code>get '/' => sub {</code><code><br>
</code><code> my $dsl = shift;</code><code><br>
</code><code> my $user = $dsl->app->request->user;</code><br>
<br>
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. <br>
<br>
Kind regards,<br>
Arjan.<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
dancer-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a>
<a class="moz-txt-link-freetext" href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Met vriendelijke groet,
Arjan Widlak
Bezoek onze site op:
<a class="moz-txt-link-freetext" href="http://www.unitedknowledge.nl">http://www.unitedknowledge.nl</a>
De rijkshuisstijl, ook voor tablet en iPhone:
<a class="moz-txt-link-freetext" href="http://www.rijkshuisstijl.unitedknowledge.nl/">http://www.rijkshuisstijl.unitedknowledge.nl/</a>
United Knowledge, inhoud en techniek
Bilderdijkstraat 79N
1053 KM Amsterdam
T +31 (0)20 737 1851
F +31 (0)84 877 0399
<a class="moz-txt-link-abbreviated" href="mailto:bureau@unitedknowledge.nl">bureau@unitedknowledge.nl</a>
<a class="moz-txt-link-freetext" href="http://www.unitedknowledge.nl">http://www.unitedknowledge.nl</a>
M +31 (0)6 2427 1444
E <a class="moz-txt-link-abbreviated" href="mailto:arjan@unitedknowledge.nl">arjan@unitedknowledge.nl</a>
We use WebGUI, the Open Source CMS
<a class="moz-txt-link-freetext" href="http://www.webgui.org/">http://www.webgui.org/</a>
</pre>
</body>
</html>