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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37fe457155877f451f702c4de046bcf9bd5cabd8a86d9bbf51cd3c4484ab10ce
4
- data.tar.gz: 642f9ddda00b7566be3001a847687bded7fc196a0e2330936f909b4753cb9eb3
3
+ metadata.gz: 5a67b420dc0efc26d3609c92e64fc8674c4edad3ad4bfbfeb75246f2fe641c4c
4
+ data.tar.gz: 70af06bd5f95c9c9e01582b64af5c4b92a79270acfc9a9d476f063e105e5c193
5
5
  SHA512:
6
- metadata.gz: b98e831598f7a901502b59950e2ae46f4393ec2fb6fab9f2d576295905ebdad31187c170fdc70f304ce4ef1d3fd14470a0001b24000869c6e96ee3ab8ee269a8
7
- data.tar.gz: 593f3909d5374c15cda3f69ae1697a59bb1b3c9a5f713aa91fde5d77656bb7a8b7b2062e618652afe7554a518e6251b219d8c3831bc9c82ddf5a6784cca1f56b
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
@@ -15,35 +15,20 @@ module Legion
15
15
  def connect_vault
16
16
  @sessions = []
17
17
  vault_settings = Legion::Settings[:crypt][:vault]
18
- protocol = vault_settings[:protocol] || 'http'
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
- if defined?(Legion::Logging) && Legion::Logging.respond_to?(:log_exception)
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module Crypt
5
- VERSION = '1.4.25'
5
+ VERSION = '1.4.27'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-crypt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.25
4
+ version: 1.4.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity