psybuzz / goldenconversations

0 stars 0 forks source link

Secret #15

Closed nikilselvam closed 10 years ago

nikilselvam commented 10 years ago

This PR changes some of the code in our configuration files.

psybuzz commented 10 years ago

Thanks Nikil for opening this PR!

The changes here reduce the work of appconfig.js. Previously, appconfig simply stored the db user and pass. Now, it will first attempt to read the user/pass values from: process.env.DB_USER and process.env.DB_PASS.

According to this Heroku FAQ: https://devcenter.heroku.com/articles/config-vars we can set the environment variables on the machine itself. I went ahead and put in the same credentials as config variables on Heroku.

If this PR is merged and pushed to Heroku, then when Heroku runs 'node app' or 'nodemon', it will check the process.env values, which should be defined, and it should work without ever having to write the password in plaintext in appconfig.js.

However, process.env.DB_USER will be undefined when we run this code locally. In order to provide appconfig the right credentials without putting the password in plaintext on Github, we could all use a secret.js file, which gets .gitignore'd. Appconfig should try to read from process.env first, and if that fails, it will look for a secret.js file at the root directory.

if (typeof process.env.DB_USER === 'undefined' || typeof process.env.DB_PASS === 'undefined'){
    var secret = require('./secret');
    process.env.DB_USER = secret.user;
    process.env.DB_PASS = secret.pass;
}

I could send both of you a secret.js, which you guys could copy into your root goldenconversations/ directory. This file DOES contain the username/password.

nikilselvam commented 10 years ago

I was just about to ask what we're specifically changing with this PR, but Erik's explanation beat me to the punch! This sounds good to me. LGTM

psybuzz commented 10 years ago

Cool! I'll wait till @tonyxj makes a comment and then merge this baby!

tonyxj commented 10 years ago

LGTM! Merge it baby iz9rzzo

psybuzz commented 10 years ago

Okay, I'm gonna go ahead and murrrge! Fingers crossed, this shouldn't break anything ;)

psybuzz commented 10 years ago

All systems green! Looks like everything's working on Heroku! Just a reminder, if you pull these changes locally, and get some error that's like: "Could not find secret.js" or something, be sure to copy the secret.js file I sent to you via email into your goldenconversations/ root directory :D