[cgiapp] app authorization patterns, best practices?
Ron Savage
ron at savage.net.au
Fri Mar 23 19:32:59 EDT 2012
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";
}
--
Ron Savage
http://savage.net.au/
Ph: 0421 920 622
More information about the cgiapp
mailing list