<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-SG" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hi all, <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Still learning Dancer2. Managed to get the database part working, but now I have a strange authentication problem – probably something I am missing.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I want to password protect several routes: <o:p></o:p></p>
<p class="MsoNormal">/secret<o:p></o:p></p>
<p class="MsoNormal">/secretpg1<o:p></o:p></p>
<p class="MsoNormal">/secretpg2<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">In config.yml, I have configured just one user, who should be able to access all the above routes:<o:p></o:p></p>
<p class="MsoNormal">engines:<o:p></o:p></p>
<p class="MsoNormal"> session:<o:p></o:p></p>
<p class="MsoNormal"> YAML:<o:p></o:p></p>
<p class="MsoNormal"> cookie_name: invictus.session<o:p></o:p></p>
<p class="MsoNormal"> is_secure: 1<o:p></o:p></p>
<p class="MsoNormal"> is_http_only: 1<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">plugins:<o:p></o:p></p>
<p class="MsoNormal"> Auth::Extensible:<o:p></o:p></p>
<p class="MsoNormal"> realms:<o:p></o:p></p>
<p class="MsoNormal"> config:<o:p></o:p></p>
<p class="MsoNormal"> provider: Config<o:p></o:p></p>
<p class="MsoNormal"> users:<o:p></o:p></p>
<p class="MsoNormal"> - user: 'joeblow'<o:p></o:p></p>
<p class="MsoNormal"> pass: 'sikrit123'<o:p></o:p></p>
<p class="MsoNormal"> name: 'Joe Blow'<o:p></o:p></p>
<p class="MsoNormal"> roles:<o:p></o:p></p>
<p class="MsoNormal"> - Marketing<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">In my Dancer2 code, I have this:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">get '/secret' => require_login sub { 'You are logged in as user: ' . logged_in_user->{name} };<o:p></o:p></p>
<p class="MsoNormal">get '/secretpg1' => require_login sub { 'This is page 1.’; };<o:p></o:p></p>
<p class="MsoNormal">get '/secretpg2' => require_login sub { 'This is page 2.’; };<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">If I go to /secret, I will get the default login page. <o:p>
</o:p></p>
<p class="MsoNormal">If I then go to /secretpg1, I thought I would get the page without having to login again, but I get redirected to the default login page again. If I login successfully then go to /secretpg2, I get asked to login again.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">What am I doing wrong here? Is there some additional configuration? I suspect there is something wrong with my config.yml, but I cannot find any information on Google that helps. All the examples I see have only one route. Help!<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks in Advance!<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-SG">pascal chong<br>
<br>
</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>