| From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> | 
|---|---|
| To: | Howard Wells <mr284(at)protonmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> | 
| Subject: | Re: How to access Postgres .pgpass file from php? | 
| Date: | 2019-09-07 22:40:22 | 
| Message-ID: | 15ad646b-2488-0413-f03c-a6bc36bbfcb5@aklaver.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
On 9/7/19 3:17 PM, Howard Wells wrote:
> I have my php files in the web root, and the Postgres 10 logon 
> credentials are in the php file.  I want to put them outside the web 
> root for security, because a malicious robot could easily read the 
> credentials.
> 
> After research, I found the .pgpass file.  That looks like the ideal 
> solution, but after even more research, I haven't found how to use that 
> file from a php logon script.
> 
> Here is the section from my php script:
> 
> $dsn = vsprintf('pgsql:host=%s;port=%s;dbname=%s;user=%s;password=%s', [
>      'host' => '000.00.00.00',
>      'port' => '5432',
>      'dbname' => '[dbname]',
>      'user' => '[username]',
>      'password' => '[password]',
> ]);
> 
> Currently I store the real dbname, user and password in the php.  My 
> questions are:
> 
> 1. How can I access it from the .pgpass file instead?
I think what you are looking for is the connection service file:
https://www.postgresql.org/docs/11/libpq-pgservice.html
> 
> 2. Where is .phpass loccated in Apache2 Ubuntu 18.04?
Information on where .pgpass can be:
https://www.postgresql.org/docs/11/libpq-pgpass.html
> 
> Thanks for any help with this.
> 
> Howard
> 
> 
> 
-- 
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jim Finnerty | 2019-09-08 01:37:32 | Whan is it safe to mark a function PARALLEL SAFE? | 
| Previous Message | Howard Wells | 2019-09-07 22:17:51 | How to access Postgres .pgpass file from php? |