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 (System) |
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::Sys; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
70691
|
use Moo; |
|
2
|
|
|
|
|
11550
|
|
|
2
|
|
|
|
|
18
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.02'; # VERSION |
13
|
2
|
|
|
2
|
|
2307
|
use namespace::clean; |
|
2
|
|
|
|
|
11608
|
|
|
2
|
|
|
|
|
12
|
|
14
|
|
|
|
|
|
|
extends 'WebService::HashiCorp::Vault::Base'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has '+mount' => ( is => 'ro', default => 'sys' ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
# /sys/audit |
21
|
|
|
|
|
|
|
# |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub audit { |
25
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
26
|
0
|
|
|
|
|
|
return $self->get( $self->_mkuri('audit') ) |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub audit_put { |
31
|
0
|
|
|
0
|
1
|
|
my ( $self, $name, %params ) = @_; |
32
|
0
|
|
|
|
|
|
return $self->_sys_put( 'audit', $name, %params ); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub audit_del { |
39
|
0
|
|
|
0
|
1
|
|
my ( $self, $name ) = @_; |
40
|
0
|
|
|
|
|
|
return $self->_sys_del( 'audit', $name ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# /sys/audit-hash |
46
|
|
|
|
|
|
|
# |
47
|
|
|
|
|
|
|
# |
48
|
|
|
|
|
|
|
# /sys/auth |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub auth { |
52
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
53
|
0
|
|
|
|
|
|
return $self->get( $self->_mkuri('auth') ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub auth_put { |
58
|
0
|
|
|
0
|
1
|
|
my ( $self, $name, %params ) = @_; |
59
|
0
|
|
|
|
|
|
return $self->_sys_put( 'audit', $name, %params ); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub auth_del { |
65
|
0
|
|
|
0
|
1
|
|
my ( $self, $name ) = @_; |
66
|
0
|
|
|
|
|
|
return $self->_sys_del( 'audit', $name ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# |
70
|
|
|
|
|
|
|
# Internal functions to do the put/del actions. |
71
|
|
|
|
|
|
|
# |
72
|
|
|
|
|
|
|
sub _sys_put { |
73
|
0
|
|
|
0
|
|
|
my ( $self, $sys_type, $name, %params ) = @_; |
74
|
0
|
|
|
|
|
|
my $uri = join '/', $self->_mkuri($sys_type), $name; |
75
|
0
|
|
|
|
|
|
return $self->post( $uri, \%params ); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _sys_del { |
80
|
0
|
|
|
0
|
|
|
my ( $self, $sys_type, $name ) = @_; |
81
|
0
|
|
|
|
|
|
my $uri = join '/', $self->_mkuri($sys_type), $name; |
82
|
0
|
|
|
|
|
|
return $self->delete( $uri ); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# /sys/capabilities |
88
|
|
|
|
|
|
|
# |
89
|
|
|
|
|
|
|
# |
90
|
|
|
|
|
|
|
# /sys/capabilities-accessor |
91
|
|
|
|
|
|
|
# |
92
|
|
|
|
|
|
|
# |
93
|
|
|
|
|
|
|
# /sys/capabilities-self |
94
|
|
|
|
|
|
|
# |
95
|
|
|
|
|
|
|
# |
96
|
|
|
|
|
|
|
# /sys/config/auditing |
97
|
|
|
|
|
|
|
# |
98
|
|
|
|
|
|
|
# |
99
|
|
|
|
|
|
|
# /sys/generate-root |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub generate_root { |
102
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
103
|
0
|
|
|
|
|
|
return $self->get( $self->_mkuri('generate-root') ) |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub health { |
108
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
109
|
0
|
|
|
|
|
|
return $self->get( $self->_mkuri('health') ) |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub init { |
114
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
115
|
0
|
|
|
|
|
|
return $self->get( $self->_mkuri('init') ) |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub key_status { |
120
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
121
|
0
|
|
|
|
|
|
return $self->get( $self->_mkuri('key-status') ) |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub leader { |
126
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
127
|
0
|
|
|
|
|
|
return $self->get( $self->_mkuri('leader') ) |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub mounts { |
132
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
133
|
0
|
|
|
|
|
|
return $self->get( $self->_mkuri('mounts') ) |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub policy { |
138
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
139
|
0
|
|
|
|
|
|
return $self->get( $self->_mkuri('policy') ) |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# /sys/raw |
143
|
|
|
|
|
|
|
# /sys/rekey |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub rekey_init { |
147
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
148
|
0
|
|
|
|
|
|
return $self->get( $self->_mkuri('rekey/init') ) |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub rekey_backup { |
153
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
154
|
0
|
|
|
|
|
|
return $self->get( $self->_mkuri('rekey/backup') ) |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
#=head2 rekey_update |
158
|
|
|
|
|
|
|
# |
159
|
|
|
|
|
|
|
# my $rekey_update = $sys->rekey_update(); |
160
|
|
|
|
|
|
|
# |
161
|
|
|
|
|
|
|
#Returns the 'rekey/update' of the vault from API location I |
162
|
|
|
|
|
|
|
# |
163
|
|
|
|
|
|
|
#The result is a hash reference |
164
|
|
|
|
|
|
|
# |
165
|
|
|
|
|
|
|
#TODO: implement DELETE |
166
|
|
|
|
|
|
|
# |
167
|
|
|
|
|
|
|
#=cut |
168
|
|
|
|
|
|
|
# |
169
|
|
|
|
|
|
|
#sub rekey_update { |
170
|
|
|
|
|
|
|
# my $self = shift; |
171
|
|
|
|
|
|
|
# return $self->get( $self->_mkuri('rekey/update') ) |
172
|
|
|
|
|
|
|
#} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# /sys/remount |
175
|
|
|
|
|
|
|
# /sys/renew |
176
|
|
|
|
|
|
|
# /sys/replication |
177
|
|
|
|
|
|
|
# /sys/revoke |
178
|
|
|
|
|
|
|
# /sys/revoke-force |
179
|
|
|
|
|
|
|
# /sys/revoke-prefix |
180
|
|
|
|
|
|
|
# /sys/rotate |
181
|
|
|
|
|
|
|
# /sys/seal |
182
|
|
|
|
|
|
|
# /sys/seal-status |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub seal_status { |
186
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
187
|
0
|
|
|
|
|
|
return $self->get( $self->_mkuri('seal-status') ) |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# /sys/step-down |
191
|
|
|
|
|
|
|
# /sys/unseal |
192
|
|
|
|
|
|
|
# /sys/wrapping/lookup |
193
|
|
|
|
|
|
|
# /sys/wrapping/rewrap |
194
|
|
|
|
|
|
|
# /sys/wrapping/unwrap |
195
|
|
|
|
|
|
|
# /sys/wrapping/wrap |
196
|
|
|
|
|
|
|
# |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
1; |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
__END__ |