line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl |
2
|
|
|
|
|
|
|
# vim: softtabstop=4 tabstop=4 shiftwidth=4 ft=perl expandtab smarttab |
3
|
|
|
|
|
|
|
# ABSTRACT: Perl API for HashiCorp's Vault |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# See also https://github.com/hashicorp/vault-ruby |
6
|
|
|
|
|
|
|
# And https://github.com/ianunruh/hvac |
7
|
|
|
|
|
|
|
# And https://www.vaultproject.io/api/index.html |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package WebService::HashiCorp::Vault; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
71526
|
use Moo; |
|
2
|
|
|
|
|
12310
|
|
|
2
|
|
|
|
|
10
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.03'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
extends 'WebService::HashiCorp::Vault::Base'; |
15
|
2
|
|
|
2
|
|
2453
|
use namespace::clean; |
|
2
|
|
|
|
|
12000
|
|
|
2
|
|
|
|
|
32
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
1681
|
use WebService::HashiCorp::Vault::Secret::Cassandra; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
71
|
|
18
|
2
|
|
|
2
|
|
1003
|
use WebService::HashiCorp::Vault::Secret::Cubbyhole; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
65
|
|
19
|
2
|
|
|
2
|
|
926
|
use WebService::HashiCorp::Vault::Secret::Generic; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
70
|
|
20
|
2
|
|
|
2
|
|
956
|
use WebService::HashiCorp::Vault::Secret::Kvv2; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
64
|
|
21
|
2
|
|
|
2
|
|
889
|
use WebService::HashiCorp::Vault::Secret::MongoDB; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
73
|
|
22
|
2
|
|
|
2
|
|
911
|
use WebService::HashiCorp::Vault::Secret::MSSQL; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
68
|
|
23
|
2
|
|
|
2
|
|
915
|
use WebService::HashiCorp::Vault::Secret::MySQL; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
76
|
|
24
|
2
|
|
|
2
|
|
909
|
use WebService::HashiCorp::Vault::Secret::PostgreSQL; |
|
2
|
|
|
|
|
17
|
|
|
2
|
|
|
|
|
64
|
|
25
|
2
|
|
|
2
|
|
957
|
use WebService::HashiCorp::Vault::Secret::RabbitMQ; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
64
|
|
26
|
2
|
|
|
2
|
|
854
|
use WebService::HashiCorp::Vault::Secret::SSH; |
|
2
|
|
|
|
|
36
|
|
|
2
|
|
|
|
|
71
|
|
27
|
2
|
|
|
2
|
|
457
|
use WebService::HashiCorp::Vault::Sys; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
693
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
{ |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my %backendmap = ( |
33
|
|
|
|
|
|
|
aws => 'AWS', |
34
|
|
|
|
|
|
|
cassandra => 'Cassandra', |
35
|
|
|
|
|
|
|
cubbyhole => 'Cubbyhole', |
36
|
|
|
|
|
|
|
consul => 'Consul', |
37
|
|
|
|
|
|
|
cubbyhole => 'Cubbyhole', |
38
|
|
|
|
|
|
|
generic => 'Generic', |
39
|
|
|
|
|
|
|
kvv2 => 'Kvv2', |
40
|
|
|
|
|
|
|
mongodb => 'MongoDB', |
41
|
|
|
|
|
|
|
mssql => 'MsSQL', |
42
|
|
|
|
|
|
|
mysql => 'MySQL', |
43
|
|
|
|
|
|
|
pki => 'PKI', |
44
|
|
|
|
|
|
|
postgresql => 'PostgreSQL', |
45
|
|
|
|
|
|
|
rabbitmq => 'RabbitMQ', |
46
|
|
|
|
|
|
|
ssh => 'SSH', |
47
|
|
|
|
|
|
|
transit => 'Transit', |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub secret { |
51
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
52
|
0
|
|
|
|
|
|
my %args = @_; |
53
|
0
|
|
|
|
|
|
$args{approle} = $self->approle(); |
54
|
0
|
|
|
|
|
|
$args{token} = $self->token(); |
55
|
0
|
|
|
|
|
|
$args{version} = $self->version(); |
56
|
0
|
|
|
|
|
|
$args{base_url} = $self->base_url(); |
57
|
0
|
|
|
|
|
|
$args{ua} = $self->ua(); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
0
|
|
|
|
$args{backend} ||= 'generic'; |
60
|
|
|
|
|
|
|
die sprintf( "Unknown backend type: %s\n", $args{backend} ) |
61
|
0
|
0
|
|
|
|
|
unless $backendmap{ lc($args{backend}) }; |
62
|
|
|
|
|
|
|
my $class = 'WebService::HashiCorp::Vault::Secret::' |
63
|
0
|
|
|
|
|
|
. $backendmap{ lc($args{backend}) }; |
64
|
0
|
|
|
|
|
|
return $class->new( %args ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub sys { |
71
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
72
|
0
|
|
|
|
|
|
my %args = @_; |
73
|
0
|
|
0
|
|
|
|
$args{mount} ||= 'sys'; |
74
|
0
|
|
|
|
|
|
$args{token} = $self->token(); |
75
|
0
|
|
|
|
|
|
$args{version} = $self->version(); |
76
|
0
|
|
|
|
|
|
$args{base_url} = $self->base_url(); |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
return WebService::HashiCorp::Vault::Sys->new( %args ); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |