line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
35
|
use utf8; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
35
|
|
2
|
|
|
|
|
|
|
package Etcd3::Auth; |
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
178
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
93
|
|
5
|
5
|
|
|
5
|
|
21
|
use warnings; |
|
5
|
|
|
|
|
24
|
|
|
5
|
|
|
|
|
127
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=encoding utf8 |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
10
|
|
|
|
|
|
|
|
11
|
5
|
|
|
5
|
|
20
|
use Moo; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
28
|
|
12
|
5
|
|
|
5
|
|
1458
|
use Carp; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
293
|
|
13
|
5
|
|
|
5
|
|
2083
|
use Types::Standard qw(Str Int Bool HashRef ArrayRef); |
|
5
|
|
|
|
|
417684
|
|
|
5
|
|
|
|
|
69
|
|
14
|
5
|
|
|
5
|
|
7993
|
use Etcd3::Auth::Role; |
|
5
|
|
|
|
|
22
|
|
|
5
|
|
|
|
|
220
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
with 'Etcd3::Role::Actions'; |
17
|
|
|
|
|
|
|
|
18
|
5
|
|
|
5
|
|
45
|
use namespace::clean; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
45
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 NAME |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Etcd3::Auth |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our $VERSION = '0.007'; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Authentication |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SYNOPSIS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# enable auth |
38
|
|
|
|
|
|
|
$etcd->user_add |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# add user |
41
|
|
|
|
|
|
|
$etcd->user_add( { name => 'samba', password =>'P@$$' }); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# add role |
44
|
|
|
|
|
|
|
$etcd->role( { name => 'myrole' })->add; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# grant role |
47
|
|
|
|
|
|
|
$etcd->user_role( { user => 'samba', role => 'myrole' })->grant; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 endpoint |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
has endpoint => ( |
56
|
|
|
|
|
|
|
is => 'ro', |
57
|
|
|
|
|
|
|
isa => Str, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 password |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has name => ( |
65
|
|
|
|
|
|
|
is => 'ro', |
66
|
|
|
|
|
|
|
isa => Str, |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 password |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
has password => ( |
74
|
|
|
|
|
|
|
is => 'ro', |
75
|
|
|
|
|
|
|
isa => Str, |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 PUBLIC METHODS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 authenticate |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Enable authentication, this requires name and password. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$etcd->auth({ name => $user, password => $pass })->authenticate; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub authenticate { |
89
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
90
|
0
|
|
|
|
|
|
$self->{endpoint} = '/auth/authenticate'; |
91
|
|
|
|
|
|
|
confess 'name and password required for ' . __PACKAGE__ . '->authenticate' |
92
|
0
|
0
|
0
|
|
|
|
unless ($self->{password} && $self->{name}); |
93
|
0
|
|
|
|
|
|
$self->request; |
94
|
0
|
|
|
|
|
|
return $self; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 enable |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Enable authentication. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
$etcd->auth()->enable; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub enable { |
106
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
107
|
0
|
|
|
|
|
|
$self->{endpoint} = '/auth/enable'; |
108
|
0
|
|
|
|
|
|
$self->{json_args} = '{}'; |
109
|
0
|
|
|
|
|
|
$self->request; |
110
|
0
|
|
|
|
|
|
return $self; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 disable |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Disable authentication, this requires a valid root password. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
$etcd->auth({ name => 'root', $password => $pass })->disable; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub disable { |
122
|
0
|
|
|
0
|
1
|
|
my ( $self, $options ) = @_; |
123
|
0
|
|
|
|
|
|
$self->{endpoint} = '/auth/disable'; |
124
|
|
|
|
|
|
|
confess 'root name and password required for ' . __PACKAGE__ . '->disable' |
125
|
0
|
0
|
0
|
|
|
|
unless ($self->{password} && $self->{name}); |
126
|
0
|
|
|
|
|
|
$self->request; |
127
|
0
|
|
|
|
|
|
return $self; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |