| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Articulate::Authorisation; |
|
2
|
4
|
|
|
4
|
|
2802
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
148
|
|
|
3
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
116
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
18
|
use Moo; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
23
|
|
|
6
|
|
|
|
|
|
|
with 'Articulate::Role::Component'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
1116
|
use Articulate::Syntax qw(instantiate_array); |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
27
|
|
|
9
|
4
|
|
|
4
|
|
973
|
use Articulate::Permission; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Articulate::Authorisation |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
plugins: |
|
20
|
|
|
|
|
|
|
Articulate::Authorisation: |
|
21
|
|
|
|
|
|
|
rules: |
|
22
|
|
|
|
|
|
|
- Articulate::Authorisation::OwnerOverride |
|
23
|
|
|
|
|
|
|
- Articulate::Authorisation::AlwaysAllow |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has rules => |
|
29
|
|
|
|
|
|
|
is => 'rw', |
|
30
|
|
|
|
|
|
|
default => sub { [] }, |
|
31
|
|
|
|
|
|
|
coerce => sub { instantiate_array(@_) }; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head3 permitted |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$self->permitted( $user_id, $permission, $location ); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Asks each of the rules in turn whether the user has the specified permission for that location. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
If so, returns the role under which they have that permission. Otherwise, returns undef. (Each provider should do likewise) |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub permitted { |
|
44
|
4
|
|
|
4
|
1
|
286
|
my $self = shift; |
|
45
|
4
|
|
|
|
|
11
|
my $user_id = shift; |
|
46
|
4
|
|
|
|
|
8
|
my $verb = shift; |
|
47
|
4
|
|
|
|
|
7
|
my $location = shift; |
|
48
|
4
|
|
|
|
|
21
|
my $p = permission ($user_id, $verb, $location); |
|
49
|
4
|
|
|
|
|
54
|
foreach my $rule ( @{ $self->rules } ) { |
|
|
4
|
|
|
|
|
88
|
|
|
50
|
8
|
|
|
|
|
724
|
my $authed_role; |
|
51
|
8
|
100
|
|
|
|
41
|
if ( |
|
|
|
50
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$rule->permitted( $p ) |
|
53
|
|
|
|
|
|
|
) { |
|
54
|
4
|
|
|
|
|
23
|
return $p; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
elsif ( $p->denied ) { |
|
57
|
0
|
|
|
|
|
|
return $p; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
} |
|
60
|
0
|
|
|
|
|
|
return ( $p->deny('No rule granted this permission') ); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=over |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item * L |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item * L |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=back |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |