line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
9
|
|
|
9
|
|
56
|
use utf8; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
61
|
|
2
|
|
|
|
|
|
|
package Net::Etcd::Auth::RolePermission; |
3
|
|
|
|
|
|
|
|
4
|
9
|
|
|
9
|
|
357
|
use strict; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
165
|
|
5
|
9
|
|
|
9
|
|
37
|
use warnings; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
196
|
|
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
39
|
use Moo; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
43
|
|
8
|
9
|
|
|
9
|
|
2858
|
use Types::Standard qw(Str Int Bool HashRef ArrayRef); |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
74
|
|
9
|
9
|
|
|
9
|
|
8636
|
use MIME::Base64; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
428
|
|
10
|
9
|
|
|
9
|
|
54
|
use Carp; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
470
|
|
11
|
9
|
|
|
9
|
|
52
|
use JSON; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
59
|
|
12
|
9
|
|
|
9
|
|
1103
|
use Data::Dumper; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
466
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
with 'Net::Etcd::Role::Actions'; |
15
|
|
|
|
|
|
|
|
16
|
9
|
|
|
9
|
|
51
|
use namespace::clean; |
|
9
|
|
|
|
|
36
|
|
|
9
|
|
|
|
|
57
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Net::Etcd::Auth::RolePermission |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '0.020'; |
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 perm |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Perm |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
has perm => ( |
106
|
|
|
|
|
|
|
is => 'lazy', |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub _build_perm { |
110
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
111
|
0
|
|
|
|
|
|
my $perm; |
112
|
0
|
|
|
|
|
|
for my $key ( keys %{$self} ) { |
|
0
|
|
|
|
|
|
|
113
|
0
|
0
|
|
|
|
|
unless ( $key =~ /(?:name|etcd|cb|endpoint)$/ ) { |
114
|
0
|
|
|
|
|
|
$perm->{$key} = $self->{$key}; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
} |
117
|
0
|
|
|
|
|
|
return $perm; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 grant |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Grant permission to role |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub grant {; |
127
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
128
|
0
|
|
|
|
|
|
$self->{endpoint} = '/auth/role/grant'; |
129
|
0
|
|
|
|
|
|
$self->{json_args} = to_json( {name => $self->name, perm => $self->perm } ); |
130
|
0
|
|
|
|
|
|
$self->request; |
131
|
0
|
|
|
|
|
|
return $self; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 revoke |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Revoke permission to role |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub revoke {; |
141
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
142
|
0
|
|
|
|
|
|
$self->{endpoint} = '/auth/role/revoke'; |
143
|
0
|
|
|
|
|
|
$self->request; |
144
|
0
|
|
|
|
|
|
return $self; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |