freeletics/creds

rails still tries to use master.key instead of <env>.key

Closed this issue · 1 comments

hi, i've implemented this gem for all my environments but when i launch rails console and check, all the configs are empty, it seems rails still uses master.key instead of the more specific keys per environment.

any tips?

seems like key_path is not properly set?

irb(main):001:0> Rails.configuration.creds.secret_key_base
=> nil
irb(main):002:0> Rails.configuration.creds
=> #<Creds:0x00007fd7b72edab0 @file_path="config/credentails/development.yml.enc", @key_path="config/master.key", @env_key="RAILS_MASTER_KEY", @raise_if_missing_key=true, @env=nil, @configuration=#<ActiveSupport::EncryptedConfiguration:0x00007fd7b9311fd0 @key_path=#<Pathname:config/master.key>, @content_path=#<Pathname:config/credentails/development.yml.enc>, @env_key="RAILS_MASTER_KEY", @raise_if_missing_key=true, @config={}, @options={}>>

config/environments/development.rb

Rails.application.configure do
  config.creds = Creds.new('config/credentails/development.yml.enc')
  ...
end

i've now changed this:

  config.creds = Creds.new('config/credentails/development.yml.enc', key_path: 'config/credentials/development.key')

this is reflected in the object itself, but the config is still empty.

EDIT: object was empty because a typo in credentails, key_path still seems needed

This might need to be reflected in the readme if it's not supposed to grab the correct key