How environment variables work inside cloud9

I want a secure way to store username

and password

API if other users don't see it in my cloud9 Ruby on Rails app. Is it safe to store them as environment variables?

I know my c9 code is public, but are these variables public?

How do I access them in the rails console? I tried ENV["VARIABLE_NAME"]

it but it doesn't seem to work in the console. Is there anything else I should be doing?

+3


source to share


1 answer


You can define environment variables in ~/.profile

. Files outside the workspace directory are /home/ubuntu/workspace

not read-only for users. You can do for example

$ echo "export SECRET=geheim" >> ~/.profile

      



to define a variable SECRET

and then use it through ENV["SECRET"]

from your application. Runners (from the run button) and terminal evaluate ~/.profile

and make the environment variable available to your application.

see also Saving secure passwords for connecting to DB in open source projects

+7


source







All Articles