4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/yaml_vault/rails.rb', line 4
def override_secrets(keys, cryptor_name = nil, **options)
config = ::Rails.application.config
::Rails.application.secrets = begin
secrets = ActiveSupport::OrderedOptions.new
yaml = config.paths["config/secrets"].first
if File.exist?(yaml)
all_secrets = YamlVault::Main.from_content(IO.read(yaml), keys, cryptor_name, **options).decrypt_hash
env_secrets = all_secrets[::Rails.env]
if env_secrets
if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new("5.1")
secrets.merge!(env_secrets.deep_symbolize_keys)
else
secrets.merge!(env_secrets.symbolize_keys)
end
end
end
secrets.secret_key_base ||= config.secret_key_base
secrets.secret_token ||= config&.secret_token if config.respond_to?(:secret_token)
secrets
end
end
|