Re: scram and \password

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Joe Conway <mail(at)joeconway(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: scram and \password
Date: 2017-04-27 07:22:26
Message-ID: 57078b66-4c6d-bd95-5d66-f4c6fc02e8e1@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 04/26/2017 07:57 PM, Tom Lane wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On Wed, Apr 26, 2017 at 6:22 AM, Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
>>> * If algorithm is not given explicitly, PQencryptPasswordConn() queries
>>> "SHOW password_encryption", and uses that. That is documented, and it is
>>> also documented that it will *not* issue queries, and hence will not block,
>>> if the algorithm is given explicitly. That's an important property for some
>>> applications. If you want the default behavior without blocking, query "SHOW
>>> password_encryption" yourself, and pass the result as the 'algorithm'.
>
>> TBH, I'd just require the user to specify the algorithm explicitly.
>> Having it run SHOW on the server seems wonky. It introduces a bunch
>> of failure modes for ... no real benefit, I think.
>
> Yeah. Blocking is the least of your worries --- what about being in
> a failed transaction, for instance?

Well, the "ALTER USER" command that you will surely run next, using the
same connection, would fail anyway. I don't think running a query is a
problem, as long as it's documented, and there's a documented way to
avoid it.

You could argue, that since we need to document how to avoid the query
and the blocking, we might as well always require the application to run
the "show password_encryption" query before calling
PQencryptPasswordConn(). But I'd like to offer the convenience for the
majority of applications that don't mind blocking.

> However, it's not entirely true that there's no real benefit. If the
> client app has to specify the algorithm then client code will need
> extension every time we add another algorithm. Maybe that's going to
> happen so seldom that it's not a big deal, but it would be nice to
> avoid that.

Yeah, I'd like to be prepared. Hopefully we don't need to add another
algorithm any time soon, but maybe we will, or maybe we want to add an
option for the SCRAM iteration count, for example.

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2017-04-27 07:25:11 Re: Vacuum: allow usage of more than 1GB of work mem
Previous Message Andres Freund 2017-04-27 07:10:09 Re: Concurrent ALTER SEQUENCE RESTART Regression