<div dir="ltr">If the session is able to distinguish each subroutine context, it would be possible.<br>I&#39;m not sure if it&#39;s supported.<br><br><div class="gmail_quote">On Tue, Dec 11, 2012 at 1:47 PM, Octavian Rasnita <span dir="ltr">&lt;<a href="mailto:orasnita@gmail.com" target="_blank">orasnita@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Maybe is a stupid suggestion that might not even be possible to do, but I think the syntax would look nicer if would be something like:<br>
<br>
get &#39;/secret&#39; =&gt; sub {<br>
   requires_login;<br>
   ...<br>
};<br>
<br>
get &#39;/beer&#39; =&gt; sub {<br>
   requires_role &#39;BeerDrinker&#39;;<br>
   ...<br>
};<br>
<br>
get &#39;/beer&#39; =&gt; sub {<br>
   requires_any_role [ &#39;BeerDrinker&#39;, &#39;VodkaDrinker&#39; ];<br>
   ...<br>
};<br>
<br>
--Octavian<br>
<br>
----- Original Message ----- From: &quot;David Precious&quot; &lt;<a href="mailto:davidp@preshweb.co.uk" target="_blank">davidp@preshweb.co.uk</a>&gt;<br>
To: &lt;<a href="mailto:dancer-users@dancer.pm" target="_blank">dancer-users@dancer.pm</a>&gt;<br>
Sent: Tuesday, December 11, 2012 1:25 PM<div class="im"><br>
Subject: [dancer-users] Dancer::Plugin::Auth::<u></u>Extensible - possible backwards-incompatible change<br>
<br>
<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><div><div class="h5">
Hi all,<br>
<br>
Whilst I really like the (ab)use of subroutine attributes for denoting<br>
which routes require authentication/specific roles, some people (whose<br>
opinions I respect) have tried to convince me that this is a Bad Idea,<br>
and is likely to be fragile.<br>
<br>
One particularly good point made is that the current implementation<br>
stores the attributes for a given route handler by the refaddr, which<br>
could be problematic if run under threads (not sure if anyone really<br>
does that, though).  Classes can provide a CLONE method to work around<br>
this, but I don&#39;t think that&#39;ll work in this case.<br>
<br>
One suggestion was to provide a new keyword, e.g. requires_auth, which<br>
would work something like:<br>
<br>
   get &#39;/secret&#39; =&gt; requires_login(sub { .... });<br>
<br>
   get &#39;/beer&#39;   =&gt; requires_role(&#39;BeerDrinker&#39;, sub { ... });<br>
<br>
(Something along those lines, at least.)  I&#39;m certain how I would<br>
implement it, though - i.e. how requires_login/requires_role would<br>
store the fact that the provided sub requires auth, without the same<br>
thread safety issues of using refaddr.<br>
<br>
Perhaps detecting the use of threads and refusing to continue would be<br>
one way of dealing with it :)<br>
<br>
Opinions on this would be very welcome.<br>
<br>
<br>
<br>
-- <br>
David Precious (&quot;bigpresh&quot;) &lt;<a href="mailto:davidp@preshweb.co.uk" target="_blank">davidp@preshweb.co.uk</a>&gt;<br>
<a href="http://www.preshweb.co.uk/" target="_blank">http://www.preshweb.co.uk/</a>     <a href="http://www.preshweb.co.uk/twitter" target="_blank">www.preshweb.co.uk/twitter</a><br>
<a href="http://www.preshweb.co.uk/linkedin" target="_blank">www.preshweb.co.uk/linkedin</a>    <a href="http://www.preshweb.co.uk/facebook" target="_blank">www.preshweb.co.uk/facebook</a><br>
<a href="http://www.preshweb.co.uk/cpan" target="_blank">www.preshweb.co.uk/cpan</a>        <a href="http://www.preshweb.co.uk/github" target="_blank">www.preshweb.co.uk/github</a><br>
<br>
<br>
______________________________<u></u>_________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm" target="_blank">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/<u></u>mailman/listinfo/dancer-users</a> <br>
</div></div></blockquote><div class="HOEnZb"><div class="h5">
<br>
______________________________<u></u>_________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm" target="_blank">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/<u></u>mailman/listinfo/dancer-users</a><br>
</div></div></blockquote></div><br></div>