Re: How to protect Postgres password in my app?

From: Grzegorz Szpetkowski <gszpetkowski(at)gmail(dot)com>
To: Basil Bourque <basil(dot)list(at)me(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to protect Postgres password in my app?
Date: 2011-05-10 20:30:49
Message-ID: BANLkTinuRUnqzZ3YXDs468LKHm3E-NsZpQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

From my view if you want application that connects to PostgreSQL
server remotely over Internet, then SSL is just best suited.
PostgreSQL has built in "out of the box" SSL authentication (for both
server and client) and of course data encryption support. You can find
in documentation about it, how to set up etc.. If your data are
sensitive I suggest to use at least 2048 bit RSA key
(http://csrc.nist.gov/publications/PubsSPs.html SP 800-57). You don't
need any password (hm, you can optionally encrypt private keys, but
note that on server side this require giving password with every
postmaster startup) Are you using JDBC library ? I think that this lib
supports SSL connection.

Regards,
Grzegorz Szpetkowski

2011/5/10 Basil Bourque <basil(dot)list(at)me(dot)com>:
> I'm an experienced programmer, but for the first time I'm developing an app that connects to a Postgres server over the internet.
>
> How do you secure the password used to connect to Postgres?
>
> My idea is to have a single user, representing my app, defined in Postgres. Then separately I'll have my own table to track each human user. I've learned about BCrypt and Postgres' encryption functions "crypt" etc. to securely store the human user's password as a value in a row in my own "user_" table.
>
> But how do I secure the app's password to connect to Postgres?
>
> a) I assume I should encrypt the connection with SSL. I'm learning about SSL certificates now. Is that the way to go? Would you consider that to be required in any serious business app connecting to Postgres over the Internets?
>
> b) Hard-coding the app's Postgres password in the app's source code seems less than ideal to me. Is there some better way?
>
> -- If the app is built in Java, I've heard that Java is very easy to de-compile and thus expose the password. Other languages such as Real Studio (REALbasic) may be not suffer that vulnerability.
>
> -- Hard-coding means I'm not free to change the password on the server. To change the password, I would have to upgrade all my users simultaneously.
>
> c) Should I manage all my human users as Postgres users? Is trying to manage the passwords on my own a dumb idea?
>
> --Basil
>
> --
> Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message JORGE MALDONADO 2011-05-10 22:30:43 Recommendation for writing a select statement.
Previous Message Stephen Cook 2011-05-10 20:29:06 Re: How to protect Postgres password in my app?