[cgiapp] app authorization patterns, best practices?
B. Estrade
estrabd at gmail.com
Wed Mar 28 09:54:01 EDT 2012
On Sat, Mar 24, 2012 at 10:32:59AM +1100, Ron Savage wrote:
> Hi Brett
>
> On 24/03/12 05:30, B. Estrade wrote:
> > https://gist.github.com/33d23edf8fa2c0f48dc0
>
> The return stmt in your groupmap code seems overly complex:
>
> #!/usr/bin/env perl
>
> use strict;
> use warnings;
> #use no autovivification;
>
> # -----------
>
> sub check
> {
> my($user, $group) = @_;
> my(%user2group) =
> (
> user1 => {all => 1, manager => 1, admin => 1},
> user2 => {all => 1, manager => 1},
> user3 => {all => 1},
> );
>
> return $user2group{$user}{$group};
>
> }
>
> # -----------
>
> for my $user (qw/user1 user2 user3 nobody/)
> {
> print "User: $user. ";
>
> for my $group (qw/all manager admin nothing/)
> {
> print "Group: $group. Check: ", check($user, $group) || 0, '. ';
> }
>
> print "\n";
> }
Very nice, thank you. And, yes, I am considering the class-based
approach. It's just that the last guy did that, too - and it's not too
pretty :)
Brett
>
>
> --
> Ron Savage
> http://savage.net.au/
> Ph: 0421 920 622
>
> ##### CGI::Application community mailing list ################
> ## ##
> ## To unsubscribe, or change your message delivery options, ##
> ## visit: http://lists.openlib.org/mailman/listinfo/cgiapp ##
> ## ##
> ## Web archive: http://lists.openlib.org/pipermail/cgiapp/ ##
> ## Wiki: http://cgiapp.erlbaum.net/ ##
> ## ##
> ################################################################
>
More information about the cgiapp
mailing list