News for hackers. Stuff that matters.
Re:Rails 4.1.0 beta1 released by 1qaz2wsx3edc on Tuesday December 17, 2013 @08:07PM (#6925170)
The only issues I have with this release is that they could of waited until after the holidays. I have a feeling we'll see a security patch right before xmas.

The second issue I have is `secrets` should be entirely removed from the framework. These settings should NOT be stored at the file level, it should be handled by environment flags. I feel this is a fundamentally broken feature.

Spring is neat, was it just a port of Zeus into Rails?

Re:Rails 4.1.0 beta1 released by tomphoolery on Tuesday December 17, 2013 @08:24PM (#6925269)
> These settings should NOT be stored at the file level, it > should be handled by environment flags. I feel this is a > fundamentally broken feature.

According to https://github.com/rails/rails/blob/master/railties/lib/rail..., this YAML file is handled like every other YAML by Rails...it's parsed through ERB first.

That means, you can do something like

    development:
      secret_key_base: <%= ENV['RAILS_SECRET'] %>
And reference it with that `Rails.configuration` business.

With this, you basically get a nice little API for recalling env variables. Pretty neat!

Re:Rails 4.1.0 beta1 released by 1qaz2wsx3edc on Tuesday December 17, 2013 @09:42PM (#6925562)
Yes, I'm aware, but what was the problem with storing configurations under `Rails.application.config.thing` as ENV['vars']?

It just seems like bloated featured.

Re:Rails 4.1.0 beta1 released by xs_kid on Tuesday December 17, 2013 @10:14PM (#6925674)
No everyone likes that approach, some people prefers to save tokens in yaml files (see on github, you will find a dozen o plugins that do same thing)
Re:Rails 4.1.0 beta1 released by 1qaz2wsx3edc on Tuesday December 17, 2013 @11:51PM (#6925971)
Just because you can, and others do, doesn't necessarily make it a good idea.

By writing & encouraging developers to use the new `secrets` API, we expose them to a bad practise. Not only that, but other solutions exist (like using `Rails.application.config`). I'm not against configuration files per-say, I'm against secrets as persisted values in a codebase.

Doing this is bad: https://github.com/search?l=ruby&q=cookie_secret&ref=cmdform...

Re:Rails 4.1.0 beta1 released by mnarayan01 on Wednesday December 18, 2013 @09:04AM (#6927517)
Presumably this would be treated just as `config/database.yml` is currently, i.e. `config/secrets.sample.yml` would be committed to the VC while `config/secrets.yml` would be ignored by the VC. When you deployed you would symlink from a shared (private) file to the secrets file.
Re:Rails 4.1.0 beta1 released by ds_ on Wednesday December 18, 2013 @03:48AM (#6926516)
Wouldn't the secrets file be added to gitignore?
Re:Rails 4.1.0 beta1 released by angryasian on Wednesday December 18, 2013 @12:05PM (#6928745)
it shouldn't be , because thats where some people will store their keys and others will reference their ENV variables.
Re:Rails 4.1.0 beta1 released by mscarborough on Tuesday December 17, 2013 @08:20PM (#6925238)
If a project owner updates prod to a new beta of a point release right during the holiday season, that's entirely their fault, not the rails team who delivered something fun for people to mess around with.
Re:Rails 4.1.0 beta1 released by 1qaz2wsx3edc on Tuesday December 17, 2013 @09:48PM (#6925592)
This is a fair criticism, I totally missed the beta flag. Cheers.
Re:Rails 4.1.0 beta1 released by steveklabnik on Tuesday December 17, 2013 @08:15PM (#6925208)
> Spring is neat, was it just a port of Zeus into Rails?

Conceptually, they're the same thing, but since Zeus is written in Go, it's totally different code.

> These settings should NOT be stored at the file level, it should be handled by environment flags. I feel this is a fundamentally broken feature.

I personally use environment variables to handle this case, but basically, every single approach has pros and cons, not to mention that there's legacy codebases... small steps.

Re:Rails 4.1.0 beta1 released by 1qaz2wsx3edc on Tuesday December 17, 2013 @09:45PM (#6925583)
> Conceptually, they're the same thing, but since Zeus is written in Go, it's totally different code.

Thank you, this is what I wanted to hear. :)

> I personally use environment variables to handle this case, but basically, every single approach has pros and cons, not to mention that there's legacy codebases... small steps.

I just think it's a bloated feature when `Rails.application.config` already exists.

Re:Rails 4.1.0 beta1 released by danso on Tuesday December 17, 2013 @08:16PM (#6925211)
No...Zeus is its own thing, AFAIK, though I guess it's described (by the Zeus maintainer) as "like Zeus but in pure Ruby, totally automatic, alpha and limited compatibility"

https://github.com/burke/zeus#related-gems

I started using Zeus a couple of weeks ago and then switched over to Spring last week...I never figured out how to get the custom Zeus files to let me run regular rails/rake commands with certain flags and parameters, but Spring pretty much worked right out of the box. It works so well that I've been wary that it might cause issues in edge cases of test configuration, but haven't run into any yet...and now that it's a part of Rails, guess I'll be even less wary.

It's definitely changed how I do TDD for Rails, in that I will actually do TDD for Rails, because the tests run so quickly. Yes, being hindered by Rails bootup just to run tests might be indicative of unneeded coupling, but sometimes a project doesn't require great abstraction, but still needs decent integration coverage. Spring is pretty handy for that.

Re:Rails 4.1.0 beta1 released by bratsche on Wednesday December 18, 2013 @02:16AM (#6926292)
Wow, that's an interesting description (the "alpha and limited compatibility" part). I've used both Zeus and Spring and I've found Spring to be more reliable. I've run into a number of issues with Zeus where it crapped out on me. I've never hit any such issues with Spring, it's felt very stable. I see the Zeus issue (#254) that plagued me the most has been fixed now though: it can now accept arbitrary-length commands. So maybe it's more usable now.
Re:Rails 4.1.0 beta1 released by jrochkind1 on Tuesday December 17, 2013 @10:40PM (#6925753)
If you don't store secrets in a file... how do you share them? When a new developer comes on board; when a new deploy machine is provisioned; etc.

Honest question, I've been trying to figure out the best way to do this.

Even without considering deploying secrets to a new machine, doesn't 'keep them in environment variables' usually mean store in a .bashrc or something, which is of course still a file?

Re:Rails 4.1.0 beta1 released by benesch on Tuesday December 17, 2013 @11:24PM (#6925891)
The idea is to keep them out of version control. At least ~/.bashrc won't end up in a repository under normal circumstances. You have no idea what pieces of your code base may eventually be open-sourced.

For small teams, a good solution is to keep a GPG-encrypted file in Dropbox or another team file share. When you onboard a new developer, someone reencrypts the file with the new recipient. If you use Chef, the knife-briefcase plugin will handle this for you.

For large teams, there shouldn't be any secrets that need to be disributed. In an ideal world, at least. Each user should get his/her own account on each server, his/her own AWS credentials, etc. At some point you'll run into sharing a secret among production servers (SSL certs, for example), but you should never need to share secrets among developers in a well-designed system. Individual accounts allows useful audit trails and limits the damage if a credential is leaked.

Re:Rails 4.1.0 beta1 released by bri3d on Tuesday December 17, 2013 @11:18PM (#6925872)
Chef encrypted databags or a similar approach where the environment variable is encrypted on disk and decrypted at runtime. Obviously your deployment nodes eventually need the secret in plaintext and all end up with the key, but at least the information is encrypted at rest (for example in your source control, a common source of breaches).

It doesn't seem wise to share secrets amongst developers (especially new ones) to me - that sounds like a recipe for disaster. GitHub accidentally deleted their production database by giving developers access to production secrets on their local machines a few years ago - regardless of how much you trust your people it's not a particularly solid plan.