legion-crypt 1.4.25 → 1.4.27
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 +15 -0
- data/lib/legion/crypt/cluster_secret.rb +3 -0
- data/lib/legion/crypt/vault.rb +30 -20
- data/lib/legion/crypt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5a67b420dc0efc26d3609c92e64fc8674c4edad3ad4bfbfeb75246f2fe641c4c
|
|
4
|
+
data.tar.gz: 70af06bd5f95c9c9e01582b64af5c4b92a79270acfc9a9d476f063e105e5c193
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: afafc5438c996024c1a13e84349d14344dc1694437e67ffe4902525e88438299fa505371eaa4b85574718bbe0e42b2fc6ffa7fc56894706c9f7cdaabe8056443
|
|
7
|
+
data.tar.gz: 4cab2713f2bd9be3c5f7270fa64e2259a883a50c6f74dbad05c0f4e0034a0ce9b29f46a9e9b2003afaf501e24448ab382dd25f9f02e254c4f71368e123394c5f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Legion::Crypt
|
|
2
2
|
|
|
3
|
+
## [1.4.27] - 2026-03-31
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- `connect_vault` now sets `::Vault.namespace` from `vault_namespace` setting, fixing 403 errors for non-cluster Vault connections in namespaced environments
|
|
7
|
+
- Extracted `resolve_vault_address` and `log_vault_connection_error` to reduce `connect_vault` complexity
|
|
8
|
+
|
|
9
|
+
## [1.4.26] - 2026-03-28
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
- `push_cs_to_vault` now rescues `StandardError` and returns `false` instead of propagating Vault errors (e.g. 403 permission denied), ensuring `set_cluster_secret` always stores the cluster secret in Settings even when the Vault write fails
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- Specs for `push_cs_to_vault` rescue path: verifies the method returns false and does not raise on Vault errors, and logs a warning when `Legion::Logging` is available
|
|
16
|
+
- Specs for `set_cluster_secret` confirming Settings assignment completes when Vault push returns false
|
|
17
|
+
|
|
3
18
|
## [1.4.25] - 2026-03-28
|
|
4
19
|
|
|
5
20
|
### Fixed
|
|
@@ -103,6 +103,9 @@ module Legion
|
|
|
103
103
|
|
|
104
104
|
Legion::Logging.info 'Pushing Cluster Secret to Vault'
|
|
105
105
|
Legion::Crypt.write('cluster', secret: Legion::Settings[:crypt][:cluster_secret])
|
|
106
|
+
rescue StandardError => e
|
|
107
|
+
Legion::Logging.warn("push_cs_to_vault failed: #{e.message}") if defined?(Legion::Logging)
|
|
108
|
+
false
|
|
106
109
|
end
|
|
107
110
|
|
|
108
111
|
def cluster_secret_timeout
|
data/lib/legion/crypt/vault.rb
CHANGED
|
@@ -15,35 +15,20 @@ module Legion
|
|
|
15
15
|
def connect_vault
|
|
16
16
|
@sessions = []
|
|
17
17
|
vault_settings = Legion::Settings[:crypt][:vault]
|
|
18
|
-
|
|
19
|
-
address = vault_settings[:address] || 'localhost'
|
|
20
|
-
port = vault_settings[:port] || 8200
|
|
21
|
-
|
|
22
|
-
if address.match?(%r{\Ahttps?://})
|
|
23
|
-
uri = URI.parse(address)
|
|
24
|
-
protocol = uri.scheme
|
|
25
|
-
address = uri.host
|
|
26
|
-
port = uri.port if vault_settings[:port].nil?
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
::Vault.address = "#{protocol}://#{address}:#{port}"
|
|
18
|
+
::Vault.address = resolve_vault_address(vault_settings)
|
|
30
19
|
|
|
31
20
|
Legion::Settings[:crypt][:vault][:token] = ENV['VAULT_DEV_ROOT_TOKEN_ID'] if ENV.key? 'VAULT_DEV_ROOT_TOKEN_ID'
|
|
32
21
|
return nil if Legion::Settings[:crypt][:vault][:token].nil?
|
|
33
22
|
|
|
34
23
|
::Vault.token = Legion::Settings[:crypt][:vault][:token]
|
|
24
|
+
namespace = vault_settings[:vault_namespace]
|
|
25
|
+
::Vault.namespace = namespace if namespace
|
|
35
26
|
if vault_healthy?
|
|
36
27
|
Legion::Settings[:crypt][:vault][:connected] = true
|
|
37
|
-
Legion::Logging.info "Vault connected at #{::Vault.address}" if defined?(Legion::Logging)
|
|
28
|
+
Legion::Logging.info "Vault connected at #{::Vault.address} (namespace=#{namespace || 'none'})" if defined?(Legion::Logging)
|
|
38
29
|
end
|
|
39
30
|
rescue StandardError => e
|
|
40
|
-
|
|
41
|
-
Legion::Logging.log_exception(e, lex: 'crypt', component_type: :helper)
|
|
42
|
-
elsif defined?(Legion::Logging) && Legion::Logging.respond_to?(:error)
|
|
43
|
-
Legion::Logging.error "Vault connection failed: #{e.class}=#{e.message}\n#{Array(e.backtrace).first(10).join("\n")}"
|
|
44
|
-
else
|
|
45
|
-
warn "Vault connection failed: #{e.class}=#{e.message}"
|
|
46
|
-
end
|
|
31
|
+
log_vault_connection_error(e)
|
|
47
32
|
Legion::Settings[:crypt][:vault][:connected] = false
|
|
48
33
|
false
|
|
49
34
|
end
|
|
@@ -206,6 +191,31 @@ module Legion
|
|
|
206
191
|
data[:data]
|
|
207
192
|
end
|
|
208
193
|
|
|
194
|
+
def resolve_vault_address(vault_settings)
|
|
195
|
+
protocol = vault_settings[:protocol] || 'http'
|
|
196
|
+
address = vault_settings[:address] || 'localhost'
|
|
197
|
+
port = vault_settings[:port] || 8200
|
|
198
|
+
|
|
199
|
+
if address.match?(%r{\Ahttps?://})
|
|
200
|
+
uri = URI.parse(address)
|
|
201
|
+
protocol = uri.scheme
|
|
202
|
+
address = uri.host
|
|
203
|
+
port = uri.port if vault_settings[:port].nil?
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
"#{protocol}://#{address}:#{port}"
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def log_vault_connection_error(error)
|
|
210
|
+
if defined?(Legion::Logging) && Legion::Logging.respond_to?(:log_exception)
|
|
211
|
+
Legion::Logging.log_exception(error, lex: 'crypt', component_type: :helper)
|
|
212
|
+
elsif defined?(Legion::Logging) && Legion::Logging.respond_to?(:error)
|
|
213
|
+
Legion::Logging.error "Vault connection failed: #{error.class}=#{error.message}\n#{Array(error.backtrace).first(10).join("\n")}"
|
|
214
|
+
else
|
|
215
|
+
warn "Vault connection failed: #{error.class}=#{error.message}"
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
209
219
|
def log_vault_debug(message)
|
|
210
220
|
Legion::Logging.debug(message) if defined?(Legion::Logging)
|
|
211
221
|
end
|
data/lib/legion/crypt/version.rb
CHANGED