0

I feel uncomfortable saving my password in a file:

require 'pg'
conn = PG::Connection.open(host: 'server.example.com', password: 'hello_everyone')

Also, is there a way to determine or ensure that the transmission is encrypted? I am just worried about the implications of running my app locally, when it must connect to a remote database (I am worried about all the data, including the authentication credentials, being sent in the clear).

1 Answer 1

1

Regarding the password:

I would recommend setting it in an ENV variable. Take a look at dotenv gem. Basically, you are going to be able to do something like:

require 'pg'
conn = PG::Connection.open(host: ENV['database_host'], password: ENV['database_password'])

The values that are loaded into ENV will be stored in a file (.env) which you should not commit.

Regarding data encryption

You should take a look at SSH tunneling to connect to the remote DB.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.