line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
9
|
|
|
9
|
|
69
|
use utf8; |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
75
|
|
2
|
|
|
|
|
|
|
package Net::Etcd::Auth::RolePermission; |
3
|
|
|
|
|
|
|
|
4
|
9
|
|
|
9
|
|
404
|
use strict; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
223
|
|
5
|
9
|
|
|
9
|
|
51
|
use warnings; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
281
|
|
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
86
|
use Moo; |
|
9
|
|
|
|
|
32
|
|
|
9
|
|
|
|
|
81
|
|
8
|
9
|
|
|
9
|
|
3575
|
use Types::Standard qw(Str Int Bool HashRef ArrayRef); |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
100
|
|
9
|
9
|
|
|
9
|
|
11583
|
use MIME::Base64; |
|
9
|
|
|
|
|
27
|
|
|
9
|
|
|
|
|
662
|
|
10
|
9
|
|
|
9
|
|
87
|
use Carp; |
|
9
|
|
|
|
|
34
|
|
|
9
|
|
|
|
|
742
|
|
11
|
9
|
|
|
9
|
|
74
|
use JSON; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
91
|
|
12
|
9
|
|
|
9
|
|
1388
|
use Data::Dumper; |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
622
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
with 'Net::Etcd::Role::Actions'; |
15
|
|
|
|
|
|
|
|
16
|
9
|
|
|
9
|
|
71
|
use namespace::clean; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
81
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Net::Etcd::Auth::RolePermission |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '0.021'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 DESCRIPTION |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Permission |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 endpoint |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has endpoint => ( |
36
|
|
|
|
|
|
|
is => 'ro', |
37
|
|
|
|
|
|
|
isa => Str, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 name |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
name of role |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has name => ( |
47
|
|
|
|
|
|
|
is => 'ro', |
48
|
|
|
|
|
|
|
isa => Str, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 role |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
name of role |
54
|
|
|
|
|
|
|
* only used in revoke, use name for grant... not my idea. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has role => ( |
59
|
|
|
|
|
|
|
is => 'ro', |
60
|
|
|
|
|
|
|
isa => Str, |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 key |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
name of key |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
has key => ( |
70
|
|
|
|
|
|
|
is => 'ro', |
71
|
|
|
|
|
|
|
isa => Str, |
72
|
|
|
|
|
|
|
required => 1, |
73
|
|
|
|
|
|
|
coerce => sub { return encode_base64( $_[0], '' ) }, |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 range_end |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
End of key range |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
has range_end => ( |
83
|
|
|
|
|
|
|
is => 'ro', |
84
|
|
|
|
|
|
|
isa => Str, |
85
|
|
|
|
|
|
|
coerce => sub { return encode_base64( $_[0], '' ) }, |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 permType |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
valid options are READ, WRITE, and READWRITE |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
has permType =>( |
95
|
|
|
|
|
|
|
is => 'ro', |
96
|
|
|
|
|
|
|
isa => Str, |
97
|
|
|
|
|
|
|
); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 prefix |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This is a helper accessor which is an alias for range_end => "\0" if passed a true value. |
102
|
|
|
|
|
|
|
If range_end is also passed prefix will superceed it's value. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
has prefix =>( |
107
|
|
|
|
|
|
|
is => 'ro', |
108
|
|
|
|
|
|
|
isa => Str, |
109
|
|
|
|
|
|
|
); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 perm |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Perm |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
has perm => ( |
118
|
|
|
|
|
|
|
is => 'lazy', |
119
|
|
|
|
|
|
|
); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _build_perm { |
122
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
123
|
0
|
|
|
|
|
|
my $perm; |
124
|
0
|
0
|
|
|
|
|
if ($self->{prefix}) { |
125
|
0
|
|
|
|
|
|
$self->{range_end} = encode_base64( "\0", '' ); |
126
|
|
|
|
|
|
|
} |
127
|
0
|
|
|
|
|
|
for my $key ( keys %{$self} ) { |
|
0
|
|
|
|
|
|
|
128
|
0
|
0
|
|
|
|
|
unless ( $key =~ /(?:prefix|name|etcd|cb|endpoint)$/ ) { |
129
|
0
|
|
|
|
|
|
$perm->{$key} = $self->{$key}; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
} |
132
|
0
|
|
|
|
|
|
return $perm; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 grant |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Grant permission to role |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub grant {; |
142
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
143
|
0
|
|
|
|
|
|
$self->{endpoint} = '/auth/role/grant'; |
144
|
0
|
|
|
|
|
|
$self->{json_args} = to_json( {name => $self->name, perm => $self->perm } ); |
145
|
0
|
|
|
|
|
|
$self->request; |
146
|
0
|
|
|
|
|
|
return $self; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 revoke |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Revoke permission to role |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub revoke {; |
156
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
157
|
0
|
|
|
|
|
|
$self->{endpoint} = '/auth/role/revoke'; |
158
|
0
|
|
|
|
|
|
$self->request; |
159
|
0
|
|
|
|
|
|
return $self; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |