Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do the environment variables work within cloud9

I want a safe way to store the username and password of an API without other people seeing it within my cloud9 Ruby on Rails app. Is it safe to save them as environment variables?

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

How do I access them within the rails console? I tried ENV["VARIABLE_NAME"] but this does not seem to work within the console. Is there anything else I should do?

like image 605
Christoph Avatar asked Aug 08 '26 22:08

Christoph


1 Answers

You can define environment variables in ~/.profile. Files outside of the workspace directory /home/ubuntu/workspace are not accessible for read only users. You can do e.g.

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

to define the variable SECRET and then use it through ENV["SECRET"] from your application. The runners (from the "run" button) and the terminal will evaluate ~/.profile and make the environment variable available to your app.

see also Storing securely passwords for connection to DB in opensource projects

like image 160
Fabian Jakobs Avatar answered Aug 10 '26 13:08

Fabian Jakobs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!