-
-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration with encrypted Rails credentials #68
Comments
Will be great |
@rdubya would you like to have a look at this one? |
Rails 5 gets away from using secrets and now has a |
I think we could add alias @smith @Darkside73 are you still interested in this? |
FYI This bug caused me so much pain... the config gem eager loads credentials, causing any overrides to not be respected in config/application.rb |
@smtlaissezfaire I would welcome a PR fixing this. Would like to have a look? I no longer work with Rails for few years now so it would be hard for me to get back to it... |
Just sharing my workaround to work with # config/initializers/config.rb
module Config
def self.load_files(*sources)
config = Options.new
# add settings sources
[sources].flatten.compact.each do |source|
config.add_source!(source)
end
config.add_source!(Sources::EnvSource.new(ENV)) if Config.use_env
load_credentials(config) # call Settings override
config.load!
config
end
# override with crendentials
def self.load_credentials(config)
if Rails.env.production? || Rails.env.staging?
# Load and replace secret from credentials
config.add_source!(Rails.application.credentials.to_h)
end
end
end
Config.setup do |config|
# your config
end |
@noxasch I like the idea of merging the Rails credentials into the I could use help understanding why the monkey patch is necessary, though. If, in an initializer, you just Settings.add_source!(Rails.application.credentials.to_h)
Settings.reload! Does that work? Or does it not have the opportunity to pick up the credentials correctly? |
@cjlarose Yup correct, you can also do that. As for me I want to load the |
Yeah, that makes sense. In a non-Rails application, Config.setup do |config|
config.use_rails_credentials = true
end I think we might have to use something like |
@noxasch would you like to fire up a PR for this change? |
Sure I can work on a PR for this @pkuczynski |
Is any help still needed? |
Rails 4.1 introduces a built-in convention for having a secrets.yml with secrets in it: http://edgeguides.rubyonrails.org/4_1_release_notes.html#config-secrets-yml
It would be cool if this gem did some of these things:
Rails.application.secrets
toSettings.secrets
I think this gem is a better overall solution to managing configuration, but if Rails is making this a thing, it would make sense to go along with it and make this gem work nicely with the new stuff.
The text was updated successfully, but these errors were encountered: