| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
4
|
|
|
4
|
|
13
|
use utf8; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
21
|
|
|
2
|
|
|
|
|
|
|
package Etcd3::Auth::Authenticate; |
|
3
|
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
124
|
use strict; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
77
|
|
|
5
|
4
|
|
|
4
|
|
12
|
use warnings; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
77
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
10
|
use Moo; |
|
|
4
|
|
|
|
|
3
|
|
|
|
4
|
|
|
|
|
22
|
|
|
8
|
4
|
|
|
4
|
|
2570
|
use Types::Standard qw(Str Int Bool HashRef ArrayRef); |
|
|
4
|
|
|
|
|
297652
|
|
|
|
4
|
|
|
|
|
42
|
|
|
9
|
4
|
|
|
4
|
|
3190
|
use MIME::Base64; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
176
|
|
|
10
|
4
|
|
|
4
|
|
15
|
use JSON; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
27
|
|
|
11
|
4
|
|
|
4
|
|
2332
|
use Data::Dumper; |
|
|
4
|
|
|
|
|
17561
|
|
|
|
4
|
|
|
|
|
209
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'Etcd3::Role::Actions'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
1500
|
use namespace::clean; |
|
|
4
|
|
|
|
|
32462
|
|
|
|
4
|
|
|
|
|
22
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Etcd3:Auth::Authenticate |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.005'; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Authentication request |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 endpoint |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has endpoint => ( |
|
34
|
|
|
|
|
|
|
is => 'ro', |
|
35
|
|
|
|
|
|
|
isa => Str, |
|
36
|
|
|
|
|
|
|
default => '/auth/authenticate' |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 username |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
the actual api uses name so we handle this in json_args |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has username => ( |
|
46
|
|
|
|
|
|
|
is => 'ro', |
|
47
|
|
|
|
|
|
|
isa => Str, |
|
48
|
|
|
|
|
|
|
required => 1, |
|
49
|
|
|
|
|
|
|
); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 password |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
has password => ( |
|
56
|
|
|
|
|
|
|
is => 'ro', |
|
57
|
|
|
|
|
|
|
isa => Str, |
|
58
|
|
|
|
|
|
|
required => 1, |
|
59
|
|
|
|
|
|
|
); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 json_args |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
arguments that will be sent to the api |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
has json_args => ( |
|
68
|
|
|
|
|
|
|
is => 'lazy', |
|
69
|
|
|
|
|
|
|
); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _build_json_args { |
|
72
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
73
|
0
|
|
|
|
|
|
my $args; |
|
74
|
0
|
|
|
|
|
|
$args->{name} = $self->{username}; |
|
75
|
0
|
|
|
|
|
|
for my $key ( keys %{ $self }) { |
|
|
0
|
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
unless ( $key =~ /(?:username|ssl|_client|json_args|endpoint)$/ ) { |
|
77
|
0
|
|
|
|
|
|
$args->{$key} = $self->{$key}; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
} |
|
80
|
0
|
|
|
|
|
|
return to_json($args); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 token |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub token { |
|
88
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
89
|
0
|
|
|
|
|
|
$self->json_args; |
|
90
|
0
|
|
|
|
|
|
my $response = $self->request; |
|
91
|
0
|
|
|
|
|
|
my $content = from_json($response->{content}); |
|
92
|
0
|
|
|
|
|
|
print STDERR Dumper($content); |
|
93
|
0
|
|
|
|
|
|
my $token = $content->{token}; |
|
94
|
0
|
|
|
|
|
|
return $token; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |