Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I securely store passwords in a configuration file in a Ruby/Rails web server environment?

I need to store payment gateway processor username/password credentials on a production web server, but would prefer not to do so in clear-text. What is the best way to store these credentials? Are their best practices for encrypting and decrypting this information?

like image 318
Brad Gessler Avatar asked Nov 21 '25 01:11

Brad Gessler


1 Answers

It's a classic chicken-egg problem. Encryption does not help you at all if you can't protect the keys. And you obviously can't.

What I would suggest is to try to make the other services / users use hashes towards your authentication code, and save those hashes instead. That way at worst you will lose the hashes, but it might prove hard (depending on the rest of the setup) to actually use them maliciously. You might also want to salt the hashes properly.

An other possibility would be using an external authentication store if you can't enforce using hashes. It does not really solve the problem, but you can control the attack vectors and make it safer by allowing only very specific contact with the actual source with the important data.


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!