| 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
| |||||||||||
| 20 | 12 | ▶ | if (grep { /$role/ } @{$user->{roles}}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 40 | |||||||||||
| 41 | 10 | my $permissions = $roles->{$role}->{permissions}; | |||||||||
| 42 | 10 | ▶ | if (defined $permissions->{$operation}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | |||||||||||
| 44 | 10 | ▶ | if ($action) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | |||||||||||
| 46 | 8 | ▶ | if (defined $permissions->{$operation}->{operations}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | |||||||||||
| 48 | 8 | my $operations = $permissions->{$operation}->{operations}; | |||||||||
| 49 | 8 | ▶ | if (grep { /$action/ } @{$operations}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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__ | ||||||||||