pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: adriantineo@softhome.net
To: pgsql-php@postgresql.org
Subject: Authenticating user
Date: Wed, 02 Oct 2002 12:39:02 -0600
Message-ID: <courier.3D9B3D46.0000179E@softhome.net> (raw)

Hi all ! 

I am coding an application where I need to identify an user with username 
and password. His credentials are checked against the corresponding 
postgresql database user. I have been reading a good tutorial at devshed.com 
about how to do this but it is done in mysql in the example. The author 
claims that the best way to check if the user is valid is by sending this 
query:
$query = "SELECT id from user WHERE username = '$user' AND
password = PASSWORD('$pass')";
This way I could see if the user is valid by counting the results returned 
by the query without returning the credentials info. 

I kind of need a PASSWORD function for postgresql. Does it exist? I have 
been searching the docs but couldn't find it. 

I have tried:
$query="SELECT usename from pg_user WHERE usename ='$user' AND 
password='$pass';
but it won't work. The only way it works is by doing this query:
$query="SELECT usename from pg_shadow WHERE usename ='$user' AND 
password='$pass';
as the postgres user but I feel that I shouldn't be using the superuser or 
the security could be in risk. 

I would appreciate any comments, thank you. 

Adrian Tineo



view thread (2+ messages)  latest in thread

Message-ID: <courier.3D9B3D46.0000179E@softhome.net>
Permalink:  ../courier.3D9B3D46.0000179E@softhome.net/
Also on:    postgresql.org/message-id/courier.3D9B3D46.0000179E@softhome.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: adriantineo@softhome.net
  Subject: Re: Authenticating user
  In-Reply-To: <courier.3D9B3D46.0000179E@softhome.net>
  References: <courier.3D9B3D46.0000179E@softhome.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox