Skip to content
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

Rails 5.1.0.beta1: Shouldn't be the line config.read_encrypted_secrets = true in all environments? #28193

Closed
sebastiandeutsch opened this issue Feb 27, 2017 · 9 comments
Labels
Milestone

Comments

@sebastiandeutsch
Copy link

sebastiandeutsch commented Feb 27, 2017

Steps to reproduce

When I run bin/rails secrets:setup it puts config.read_encrypted_secrets = true in my production environment (or it was there before) - but to use it as desired I need to put config.read_encrypted_secrets = true in all my environments.

Expected behavior

I don't expect Rails.application.secrets to be missing my secrets.yml.enc in development.

Actual behavior

Well... the keys are missing.

System configuration

uname -a
Darwin localhost 16.1.0 Darwin Kernel Version 16.1.0: Thu Oct 13 21:26:57 PDT 2016; root:xnu-3789.21.3~60/RELEASE_X86_64 x86_64
rails --version
5.1.0.beta1
ruby --version
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
@sebastiandeutsch sebastiandeutsch changed the title Shouldn't be config.read_encrypted_secrets = true in all environments? Shouldn't be config.read_encrypted_secrets = true in all environments? Feb 27, 2017
@sebastiandeutsch sebastiandeutsch changed the title Shouldn't be config.read_encrypted_secrets = true in all environments? Shouldn't be the line config.read_encrypted_secrets = true in all environments? Feb 27, 2017
@sebastiandeutsch sebastiandeutsch changed the title Shouldn't be the line config.read_encrypted_secrets = true in all environments? Rails 5.1.0.beta1: Shouldn't be the line config.read_encrypted_secrets = true in all environments? Feb 27, 2017
@matthewd
Copy link
Member

I'm not sure how helpful that would be.

It seems to me, if you're going to require the decryption keys to be present on any machine that wants to boot the application, even in development or test, you might as well just git-ignore secrets.yml, and distribute it via whatever side-channel you're using to widely share the key.

In my mind, the value of the encryption is that you can keep the secrets with the application while only needing to distribute the keys to the subset of deployments that actually need the "secret secrets".

to use it as desired

Can you elaborate on your intended use case, perhaps? If every clone of the repository needs the keys in order to be useful, which dangers/attacks are being thwarted by the encryption?

@sebastiandeutsch
Copy link
Author

sebastiandeutsch commented Feb 27, 2017

Currently I have an application where I'm authenticating a user with Facebook. Every environment has it's own Facebook App Secret (development / staging / production) since OAuth redirect URLs must match the specific servers.

I thought that secrets.yml.enc would be the best place for this.

Sure I could add all of this to secrets.yml and put this into .gitignore. But that would mean that I need to distribute Facebook App Secrets to my team for all environments or send the secrets.yml directly.

With the new mechanism I just need to distribute the key.

@sebastiandeutsch
Copy link
Author

Alternatively we could adapt the documentation to state:

say "Add this to your config/environments/(development|production).rb:"
say "config.read_encrypted_secrets = true"

But please tell me if I got the whole thing wrong :-)

@matthewd
Copy link
Member

But that would mean that I need to distribute Facebook App Secrets to my team for all environments or send the secrets.yml directly.

With the new mechanism I just need to distribute the key.

Right.. but either way, you're distributing a single file / string. What makes this string better than the other one?


Personally, I'd put the production and staging keys in secrets.yml.enc, and the development key in secrets.yml. That way no-one's laptop contains the production key. (For this purpose, I'm counting "contains an encrypted file holding X with a decryption key next to it" as "contains X".)

@sebastiandeutsch
Copy link
Author

If I can choose between sharing string or a yml file I'd prefer the string - but I guess I'm nit-picking here so I'll elaborate the full process: I was trying out the new mechanism (out of curiosity) and in development the keys didn't show up until I've added the line from above to the development.rb.

What do you think about adopting the documentation to let the user decide in which environment he wants to use the mechanism? Or do you even discourage people to use secrets.yml.enc in development?

@rafaelfranca rafaelfranca added this to the 5.1.0 milestone Feb 28, 2017
@kaspth
Copy link
Contributor

kaspth commented Mar 6, 2017

Or do you even discourage people to use secrets.yml.enc in development?

We're only going to recommend it for production secrets, yes. Feel free to try your hand at a doc PR that elaborates on the read_encrypted_secrets config (just explaining that it's there, but it shouldn't recommend adding it in dev, test).

@kaspth kaspth closed this as completed Mar 6, 2017
@sebastiandeutsch
Copy link
Author

Ok cool. Could you point me to the source of the docs and I'll write up my findings.

@kaspth
Copy link
Contributor

kaspth commented Mar 9, 2017

@sebastiandeutsch took a stab at it in b16dcc8 since we're (hopefully) close to another release. Thanks!

kaspth added a commit that referenced this issue Mar 9, 2017
Mostly just that it's there.

Closes #28193.
@sebastiandeutsch
Copy link
Author

Sweet :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants