<div dir="ltr">If the session is able to distinguish each subroutine context, it would be possible.<br>I'm not sure if it's supported.<br><br><div class="gmail_quote">On Tue, Dec 11, 2012 at 1:47 PM, Octavian Rasnita <span dir="ltr"><<a href="mailto:orasnita@gmail.com" target="_blank">orasnita@gmail.com</a>></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 '/secret' => sub {<br>
requires_login;<br>
...<br>
};<br>
<br>
get '/beer' => sub {<br>
requires_role 'BeerDrinker';<br>
...<br>
};<br>
<br>
get '/beer' => sub {<br>
requires_any_role [ 'BeerDrinker', 'VodkaDrinker' ];<br>
...<br>
};<br>
<br>
--Octavian<br>
<br>
----- Original Message ----- From: "David Precious" <<a href="mailto:davidp@preshweb.co.uk" target="_blank">davidp@preshweb.co.uk</a>><br>
To: <<a href="mailto:dancer-users@dancer.pm" target="_blank">dancer-users@dancer.pm</a>><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't think that'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 '/secret' => requires_login(sub { .... });<br>
<br>
get '/beer' => requires_role('BeerDrinker', sub { ... });<br>
<br>
(Something along those lines, at least.) I'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 ("bigpresh") <<a href="mailto:davidp@preshweb.co.uk" target="_blank">davidp@preshweb.co.uk</a>><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>