pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedprotocol, md5 authentication
7+ messages / 4 participants
[nested] [flat]
* protocol, md5 authentication
@ 2006-02-22 14:22 Josh Close <narshe@gmail.com>
2006-02-22 16:30 ` Re: protocol, md5 authentication James William Pye <pgsql@jwp.name>
2006-02-22 16:48 ` Re: protocol, md5 authentication Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 7+ messages in thread
From: Josh Close @ 2006-02-22 14:22 UTC (permalink / raw)
To: pgsql-interfaces
I can't seem to get the md5 authentication to work with the postgres
protocol version 3.
The docs don't really say how to send an authenticated password, just that
you need to use the returned salt from the md5 authentication request.
I've read somewhere that it needs to work like this:
1. Combine password + user.
2. MD5 hash the result.
3. Add the salt to the end of that.
4. Hash the result.
5. Add "md5" to the front of this, so postgres knows it's md5.
This hasn't worked for me.
What is the correct way of MD5 authenticating?
-Josh
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: protocol, md5 authentication
2006-02-22 14:22 protocol, md5 authentication Josh Close <narshe@gmail.com>
@ 2006-02-22 16:30 ` James William Pye <pgsql@jwp.name>
2006-02-22 16:53 ` Re: protocol, md5 authentication Josh Close <narshe@gmail.com>
1 sibling, 1 reply; 7+ messages in thread
From: James William Pye @ 2006-02-22 16:30 UTC (permalink / raw)
To: Josh Close <narshe@gmail.com>; +Cc: pgsql-interfaces
On Wed, Feb 22, 2006 at 08:22:51AM -0600, Josh Close wrote:
> What is the correct way of MD5 authenticating?
libpq implements it properly. I'd suggest looking at the client source.
Also, I *think* I have this working correctly in my PQueue module, so if you
don't mind a little Python:
import md5
pw = md5.new(self.password + self.keywords['user']).hexdigest()
pw = 'md5' + md5.new(pw + authmsg.salt).hexdigest()
self.password is the password given by the user.
self.keywords['user'] is the user name.
authmsg.salt is the salt given by the server.
Where 'pw' is sent back to the server in a Password message.
(mrm, can't remember if/when I tested this.. =\)
--
Regards, James William Pye
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: protocol, md5 authentication
2006-02-22 14:22 protocol, md5 authentication Josh Close <narshe@gmail.com>
2006-02-22 16:30 ` Re: protocol, md5 authentication James William Pye <pgsql@jwp.name>
@ 2006-02-22 16:53 ` Josh Close <narshe@gmail.com>
2006-02-22 18:55 ` Re: protocol, md5 authentication James William Pye <pgsql@jwp.name>
0 siblings, 1 reply; 7+ messages in thread
From: Josh Close @ 2006-02-22 16:53 UTC (permalink / raw)
To: pgsql-interfaces
>
> libpq implements it properly. I'd suggest looking at the client source.
Where would that be, in the postgres source? And what file? I'm really not
too familiar with C.
Also, I *think* I have this working correctly in my PQueue module, so if you
> don't mind a little Python:
>
> import md5
> pw = md5.new(self.password + self.keywords['user']).hexdigest()
> pw = 'md5' + md5.new (pw + authmsg.salt).hexdigest()
>
> self.password is the password given by the user.
> self.keywords['user'] is the user name.
> authmsg.salt is the salt given by the server.
Yeah, I love Python. That is actually the way I'm sending it also. I'm
connecting via .NET though. I'll have to double check some things.
-Josh
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: protocol, md5 authentication
2006-02-22 14:22 protocol, md5 authentication Josh Close <narshe@gmail.com>
2006-02-22 16:30 ` Re: protocol, md5 authentication James William Pye <pgsql@jwp.name>
2006-02-22 16:53 ` Re: protocol, md5 authentication Josh Close <narshe@gmail.com>
@ 2006-02-22 18:55 ` James William Pye <pgsql@jwp.name>
2006-02-22 21:06 ` Re: protocol, md5 authentication Alvaro Herrera <alvherre@commandprompt.com>
0 siblings, 1 reply; 7+ messages in thread
From: James William Pye @ 2006-02-22 18:55 UTC (permalink / raw)
To: Josh Close <narshe@gmail.com>; +Cc: pgsql-interfaces
On Wed, Feb 22, 2006 at 10:53:45AM -0600, Josh Close wrote:
> Where would that be, in the postgres source? And what file? I'm really not
> too familiar with C.
Yes, in PostgreSQL's source distribution(or CVS).
src/interfaces/libpq
libpq-auth.c seems like a good place to start. Look for md5 in that file and
follow that around.
> Yeah, I love Python. That is actually the way I'm sending it also. I'm
> connecting via .NET though. I'll have to double check some things.
I guessed that you were developing a driver. If that is the case, then I am
pretty sure that that should be working. Additionally, make sure the password
you are trying works when you connect with trusty ol' psql.
If you are not writing a driver, then this should, imo, already be taken care of
[by the driver you are using].
--
Regards, James William Pye
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: protocol, md5 authentication
2006-02-22 14:22 protocol, md5 authentication Josh Close <narshe@gmail.com>
2006-02-22 16:30 ` Re: protocol, md5 authentication James William Pye <pgsql@jwp.name>
2006-02-22 16:53 ` Re: protocol, md5 authentication Josh Close <narshe@gmail.com>
2006-02-22 18:55 ` Re: protocol, md5 authentication James William Pye <pgsql@jwp.name>
@ 2006-02-22 21:06 ` Alvaro Herrera <alvherre@commandprompt.com>
0 siblings, 0 replies; 7+ messages in thread
From: Alvaro Herrera @ 2006-02-22 21:06 UTC (permalink / raw)
To: Josh Close <narshe@gmail.com>; pgsql-interfaces
James William Pye wrote:
> On Wed, Feb 22, 2006 at 10:53:45AM -0600, Josh Close wrote:
> > Where would that be, in the postgres source? And what file? I'm really not
> > too familiar with C.
>
> Yes, in PostgreSQL's source distribution(or CVS).
>
> src/interfaces/libpq
>
> libpq-auth.c seems like a good place to start. Look for md5 in that file and
> follow that around.
That code can be seen here:
http://projects.commandprompt.com/projects/public/pgsql/browser/trunk/pgsql/src/interfaces/libpq/
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: protocol, md5 authentication
2006-02-22 14:22 protocol, md5 authentication Josh Close <narshe@gmail.com>
@ 2006-02-22 16:48 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-02-22 17:11 ` Re: protocol, md5 authentication Josh Close <narshe@gmail.com>
1 sibling, 1 reply; 7+ messages in thread
From: Tom Lane @ 2006-02-22 16:48 UTC (permalink / raw)
To: Josh Close <narshe@gmail.com>; +Cc: pgsql-interfaces
"Josh Close" <narshe@gmail.com> writes:
> I can't seem to get the md5 authentication to work with the postgres
> protocol version 3.
Define "work" --- what are you trying to do and what is happening?
If you are using any of the standard client libraries such as libpq,
the use of password encryption should be completely transparent to
you. You certainly do not hand in a pre-encrypted password or anything
like that.
regards, tom lane
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: protocol, md5 authentication
2006-02-22 14:22 protocol, md5 authentication Josh Close <narshe@gmail.com>
2006-02-22 16:48 ` Re: protocol, md5 authentication Tom Lane <tgl@sss.pgh.pa.us>
@ 2006-02-22 17:11 ` Josh Close <narshe@gmail.com>
0 siblings, 0 replies; 7+ messages in thread
From: Josh Close @ 2006-02-22 17:11 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-interfaces
>
> Define "work" --- what are you trying to do and what is happening?
>
> If you are using any of the standard client libraries such as libpq,
> the use of password encryption should be completely transparent to
> you. You certainly do not hand in a pre-encrypted password or anything
> like that.
>
I'm connecting via a socket and using Postgres protocol version 3. I'll need
to encrypt all that myself then.
I must have made a mistake somewhere else in my code, because I think I'm
doing the encryption write from what James said in his reply about his
python method.
-Josh
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2006-02-22 21:06 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-02-22 14:22 protocol, md5 authentication Josh Close <narshe@gmail.com>
2006-02-22 16:30 ` James William Pye <pgsql@jwp.name>
2006-02-22 16:53 ` Josh Close <narshe@gmail.com>
2006-02-22 18:55 ` James William Pye <pgsql@jwp.name>
2006-02-22 21:06 ` Alvaro Herrera <alvherre@commandprompt.com>
2006-02-22 16:48 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-02-22 17:11 ` Josh Close <narshe@gmail.com>
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