line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
13
|
use utf8; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
16
|
|
2
|
|
|
|
|
|
|
package Etcd3::Auth::Authenticate; |
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
93
|
use strict; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
41
|
|
5
|
3
|
|
|
3
|
|
8
|
use warnings; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
62
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
9
|
use Moo; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
16
|
|
8
|
3
|
|
|
3
|
|
2007
|
use Types::Standard qw(Str Int Bool HashRef ArrayRef); |
|
3
|
|
|
|
|
139408
|
|
|
3
|
|
|
|
|
29
|
|
9
|
3
|
|
|
3
|
|
2451
|
use MIME::Base64; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
151
|
|
10
|
3
|
|
|
3
|
|
13
|
use JSON; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
20
|
|
11
|
3
|
|
|
3
|
|
1988
|
use Data::Dumper; |
|
3
|
|
|
|
|
12965
|
|
|
3
|
|
|
|
|
199
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'Etcd3::Role::Actions'; |
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
1369
|
use namespace::clean; |
|
3
|
|
|
|
|
24072
|
|
|
3
|
|
|
|
|
11
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Etcd3:Auth::Authenticate |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
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; |