lex-vault 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/CLAUDE.md +35 -46
- data/README.md +79 -2
- data/lib/legion/extensions/vault/auth/helpers/login.rb +27 -0
- data/lib/legion/extensions/vault/auth/runners/app_role.rb +26 -0
- data/lib/legion/extensions/vault/auth/runners/token.rb +24 -0
- data/lib/legion/extensions/vault/auth/runners/user_pass.rb +26 -0
- data/lib/legion/extensions/vault/auth.rb +33 -0
- data/lib/legion/extensions/vault/client.rb +12 -2
- data/lib/legion/extensions/vault/errors.rb +48 -0
- data/lib/legion/extensions/vault/helpers/auth.rb +67 -0
- data/lib/legion/extensions/vault/helpers/client.rb +28 -1
- data/lib/legion/extensions/vault/runners/consul.rb +61 -0
- data/lib/legion/extensions/vault/runners/kv.rb +41 -33
- data/lib/legion/extensions/vault/runners/leases.rb +11 -10
- data/lib/legion/extensions/vault/runners/namespaces.rb +11 -10
- data/lib/legion/extensions/vault/runners/nomad.rb +72 -0
- data/lib/legion/extensions/vault/runners/pki.rb +30 -25
- data/lib/legion/extensions/vault/runners/system.rb +53 -39
- data/lib/legion/extensions/vault/runners/token.rb +35 -31
- data/lib/legion/extensions/vault/runners/transit.rb +23 -31
- data/lib/legion/extensions/vault/version.rb +1 -1
- data/lib/legion/extensions/vault.rb +30 -0
- metadata +10 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'legion/extensions/vault/errors'
|
|
3
4
|
require 'legion/extensions/vault/helpers/client'
|
|
4
5
|
|
|
5
6
|
module Legion
|
|
@@ -9,76 +10,67 @@ module Legion
|
|
|
9
10
|
module Transit
|
|
10
11
|
include Legion::Extensions::Vault::Helpers::Client
|
|
11
12
|
|
|
12
|
-
def create_key(name:, mount: 'transit', type: nil, **)
|
|
13
|
+
def create_key(name:, mount: 'transit', type: nil, read_only: false, **)
|
|
14
|
+
raise Legion::Extensions::Vault::Errors::ReadOnlyError, 'write operations disabled (read_only mode)' if read_only
|
|
15
|
+
|
|
13
16
|
body = type ? { type: type } : {}
|
|
14
|
-
|
|
15
|
-
{ result: response.status == 204 }
|
|
17
|
+
{ status: connection(**).post("/v1/#{mount}/keys/#{name}", body).status }
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
def read_key(name:, mount: 'transit', **)
|
|
19
|
-
|
|
20
|
-
{ result: response.body }
|
|
21
|
+
vault_normalize(connection(**).get("/v1/#{mount}/keys/#{name}").body)
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
def list_keys(mount: 'transit', **)
|
|
24
|
-
|
|
25
|
-
{ result: response.body }
|
|
25
|
+
vault_normalize(connection(**).get("/v1/#{mount}/keys", { list: true }).body)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def delete_key(name:, mount: 'transit', **)
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
def delete_key(name:, mount: 'transit', read_only: false, **)
|
|
29
|
+
raise Legion::Extensions::Vault::Errors::ReadOnlyError, 'write operations disabled (read_only mode)' if read_only
|
|
30
|
+
|
|
31
|
+
{ status: connection(**).delete("/v1/#{mount}/keys/#{name}").status }
|
|
31
32
|
end
|
|
32
33
|
|
|
33
|
-
def rotate_key(name:, mount: 'transit', **)
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
def rotate_key(name:, mount: 'transit', read_only: false, **)
|
|
35
|
+
raise Legion::Extensions::Vault::Errors::ReadOnlyError, 'write operations disabled (read_only mode)' if read_only
|
|
36
|
+
|
|
37
|
+
{ status: connection(**).post("/v1/#{mount}/keys/#{name}/rotate").status }
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
def encrypt(name:, plaintext:, mount: 'transit', context: nil, **)
|
|
39
41
|
body = { plaintext: plaintext, context: context }.compact
|
|
40
|
-
|
|
41
|
-
{ result: response.body }
|
|
42
|
+
vault_normalize(connection(**).post("/v1/#{mount}/encrypt/#{name}", body).body)
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
def decrypt(name:, ciphertext:, mount: 'transit', context: nil, **)
|
|
45
46
|
body = { ciphertext: ciphertext, context: context }.compact
|
|
46
|
-
|
|
47
|
-
{ result: response.body }
|
|
47
|
+
vault_normalize(connection(**).post("/v1/#{mount}/decrypt/#{name}", body).body)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def rewrap(name:, ciphertext:, mount: 'transit', **)
|
|
51
|
-
|
|
52
|
-
{ result: response.body }
|
|
51
|
+
vault_normalize(connection(**).post("/v1/#{mount}/rewrap/#{name}", { ciphertext: ciphertext }).body)
|
|
53
52
|
end
|
|
54
53
|
|
|
55
54
|
def datakey(name:, key_type: 'plaintext', mount: 'transit', **)
|
|
56
|
-
|
|
57
|
-
{ result: response.body }
|
|
55
|
+
vault_normalize(connection(**).post("/v1/#{mount}/datakey/#{key_type}/#{name}").body)
|
|
58
56
|
end
|
|
59
57
|
|
|
60
58
|
def sign(name:, input:, mount: 'transit', hash_algorithm: nil, **)
|
|
61
59
|
body = { input: input, hash_algorithm: hash_algorithm }.compact
|
|
62
|
-
|
|
63
|
-
response = connection(**).post(path, body)
|
|
64
|
-
{ result: response.body }
|
|
60
|
+
vault_normalize(connection(**).post("/v1/#{mount}/sign/#{name}", body).body)
|
|
65
61
|
end
|
|
66
62
|
|
|
67
63
|
def verify(name:, input:, signature:, mount: 'transit', hash_algorithm: nil, **)
|
|
68
64
|
body = { input: input, signature: signature, hash_algorithm: hash_algorithm }.compact
|
|
69
|
-
|
|
70
|
-
response = connection(**).post(path, body)
|
|
71
|
-
{ result: response.body }
|
|
65
|
+
vault_normalize(connection(**).post("/v1/#{mount}/verify/#{name}", body).body)
|
|
72
66
|
end
|
|
73
67
|
|
|
74
68
|
def hash_data(input:, mount: 'transit', algorithm: 'sha2-256', **)
|
|
75
|
-
|
|
76
|
-
{ result: response.body }
|
|
69
|
+
vault_normalize(connection(**).post("/v1/#{mount}/hash/#{algorithm}", { input: input }).body)
|
|
77
70
|
end
|
|
78
71
|
|
|
79
72
|
def random_bytes(bytes: 32, mount: 'transit', format: 'base64', **)
|
|
80
|
-
|
|
81
|
-
{ result: response.body }
|
|
73
|
+
vault_normalize(connection(**).post("/v1/#{mount}/random/#{bytes}", { format: format }).body)
|
|
82
74
|
end
|
|
83
75
|
|
|
84
76
|
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers, false) &&
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'legion/extensions/vault/version'
|
|
4
|
+
require 'legion/extensions/vault/errors'
|
|
5
|
+
require 'legion/extensions/vault/auth'
|
|
6
|
+
require 'legion/extensions/vault/helpers/auth'
|
|
4
7
|
require 'legion/extensions/vault/helpers/client'
|
|
5
8
|
require 'legion/extensions/vault/runners/system'
|
|
6
9
|
require 'legion/extensions/vault/runners/kv'
|
|
@@ -9,12 +12,39 @@ require 'legion/extensions/vault/runners/transit'
|
|
|
9
12
|
require 'legion/extensions/vault/runners/pki'
|
|
10
13
|
require 'legion/extensions/vault/runners/leases'
|
|
11
14
|
require 'legion/extensions/vault/runners/namespaces'
|
|
15
|
+
require 'legion/extensions/vault/runners/consul'
|
|
16
|
+
require 'legion/extensions/vault/runners/nomad'
|
|
12
17
|
require 'legion/extensions/vault/client'
|
|
13
18
|
|
|
14
19
|
module Legion
|
|
15
20
|
module Extensions
|
|
16
21
|
module Vault
|
|
17
22
|
extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core, false
|
|
23
|
+
|
|
24
|
+
# No async/AMQP dispatch surface. The task engine does not promise
|
|
25
|
+
# exactly-once execution, and queuing secrets-engine side effects
|
|
26
|
+
# (unseal, put_policy, revoke, writes) behind redelivery is a mismatch.
|
|
27
|
+
# Vault calls are fast synchronous HTTP; use in-process/Client/MCP paths.
|
|
28
|
+
def self.remote_invocable?
|
|
29
|
+
false
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.default_settings
|
|
33
|
+
{
|
|
34
|
+
address: 'http://127.0.0.1:8200',
|
|
35
|
+
token: nil,
|
|
36
|
+
namespace: nil,
|
|
37
|
+
runners: {
|
|
38
|
+
kv: { desc: 'KV v2 secret engine operations' },
|
|
39
|
+
token: { desc: 'Token auth engine management' },
|
|
40
|
+
transit: { desc: 'Transit encryption engine operations' },
|
|
41
|
+
pki: { desc: 'PKI certificate engine operations' },
|
|
42
|
+
leases: { desc: 'Lease lookup, renewal, and revocation' },
|
|
43
|
+
namespaces: { desc: 'Enterprise namespace management' },
|
|
44
|
+
system: { desc: 'Vault system and mount administration' }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
end
|
|
18
48
|
end
|
|
19
49
|
end
|
|
20
50
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lex-vault
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Esity
|
|
@@ -142,11 +142,20 @@ files:
|
|
|
142
142
|
- README.md
|
|
143
143
|
- lex-vault.gemspec
|
|
144
144
|
- lib/legion/extensions/vault.rb
|
|
145
|
+
- lib/legion/extensions/vault/auth.rb
|
|
146
|
+
- lib/legion/extensions/vault/auth/helpers/login.rb
|
|
147
|
+
- lib/legion/extensions/vault/auth/runners/app_role.rb
|
|
148
|
+
- lib/legion/extensions/vault/auth/runners/token.rb
|
|
149
|
+
- lib/legion/extensions/vault/auth/runners/user_pass.rb
|
|
145
150
|
- lib/legion/extensions/vault/client.rb
|
|
151
|
+
- lib/legion/extensions/vault/errors.rb
|
|
152
|
+
- lib/legion/extensions/vault/helpers/auth.rb
|
|
146
153
|
- lib/legion/extensions/vault/helpers/client.rb
|
|
154
|
+
- lib/legion/extensions/vault/runners/consul.rb
|
|
147
155
|
- lib/legion/extensions/vault/runners/kv.rb
|
|
148
156
|
- lib/legion/extensions/vault/runners/leases.rb
|
|
149
157
|
- lib/legion/extensions/vault/runners/namespaces.rb
|
|
158
|
+
- lib/legion/extensions/vault/runners/nomad.rb
|
|
150
159
|
- lib/legion/extensions/vault/runners/pki.rb
|
|
151
160
|
- lib/legion/extensions/vault/runners/system.rb
|
|
152
161
|
- lib/legion/extensions/vault/runners/token.rb
|