RBAC/Permissions/Config.pm

filter: Statementstmt 100% 40 / 40 Branchbran 78.5% 11 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 95.1% 59 / 62 CC 9 SCAR 14.9
CC
9
Cov
94%
subject_can
7.0
subject_asa
3.0
BEGIN
1.0
CRAP 4.4
« RBAC.pm ↑ Summary RBAC/Permissions.pm »
1 # ABSTRACT: Dancer::Plugin::Auth::RBAC access control via the Dancer configuration file!
2  
3 package Dancer::Plugin::Auth::RBAC::Permissions::Config;
4 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 $Dancer::Plugin::Auth::RBAC::Permissions::Config::VERSION = '1.110720';
6 }
7  
8 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use base qw/Dancer::Plugin::Auth::RBAC::Permissions/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 12 ▶sub subject_asa {
Subroutine subject_asa: called CC=3 SCAR=11.0
Pod documented
14 12 my ($self, $options, @arguments) = @_;
15 12 my $role = shift @arguments;
16 12 my $user = $self->credentials;
17 12 my $settings = $class::settings;
18
19 12 ▶ if ($role) {
Branch: 1 branch
BranchTrueFalseTotal
if ($role) 12 0 12
20 12 ▶ if (grep { /$role/ } @{$user->{roles}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {/$role/;} @{$$user{"roles"};}) 3 9 12
21 3 return 1;
22 }
23 }
24
25 9 return 0;
26 }
27  
28  
29 10 ▶sub subject_can {
Subroutine subject_can: called CC=7 SCAR=19.5
Pod documented
30 10 my ($self, $options, @arguments) = @_;
31 10 my ($operation, $action) = @arguments;
32 10 my $settings = $class::settings;
33
34 10 my $user = $self->credentials;
35 10 my $roles = $options->{control};
36
37 10 foreach my $role ( @{$user->{roles}} ) {
38
39 15 ▶ if (defined $roles->{$role}->{permissions}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $roles->{$role}{"permissions"}) 10 5 15
40
41 10 my $permissions = $roles->{$role}->{permissions};
42 10 ▶ if (defined $permissions->{$operation}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $permissions->{$operation}) 10 0 10
43
44 10 ▶ if ($action) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action) { } 8 2 10
45  
46 8 ▶ if (defined $permissions->{$operation}->{operations}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $permissions->{$operation}{"operations"}) 8 0 8
47
48 8 my $operations = $permissions->{$operation}->{operations};
49 8 ▶ if (grep { /$action/ } @{$operations}) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {/$action/;} @{$operations;}) 6 2 8
50
51 6 return 1;
52
53 }
54
55 }
56  
57 }
58 else {
59 2 return 1;
60 }
61
62 }
63
64 }
65
66 }
67
68 2 return 0;
69 }
70  
71 2 1;
72 __END__
« RBAC.pm ↑ Summary RBAC/Permissions.pm »