Re: Password identifiers, protocol aging and SCRAM protocol - Mailing list pgsql-hackers
From | Michael Paquier |
---|---|
Subject | Re: Password identifiers, protocol aging and SCRAM protocol |
Date | |
Msg-id | CAB7nPqSSzWEc-7S2VhenA36xTFa2mDxmb4erUApca8vc6bG9iw@mail.gmail.com Whole thread Raw |
In response to | Re: Password identifiers, protocol aging and SCRAM protocol (Robert Haas <robertmhaas@gmail.com>) |
Responses |
Re: Password identifiers, protocol aging and SCRAM protocol
|
List | pgsql-hackers |
On Thu, Mar 31, 2016 at 1:14 AM, Robert Haas <robertmhaas@gmail.com> wrote: > On Wed, Mar 30, 2016 at 9:46 AM, Michael Paquier > <michael.paquier@gmail.com> wrote: >>> Things I noticed: >>> 1. >>> when using either >>> CREATE ROLE >>> ALTER ROLE >>> with the parameter >>> ENCRYPTED >>> md5 encryption is always assumed (I've come to realize that UNENCRYPTED >>> always equals plain and, in the past, ENCRYPTED equaled md5 since there were >>> no other options) >> >> Yes, that's to match the current behavior, and make something fully >> backward-compatible. Switching to md5 + scram may have made sense as >> well though. > > I think we're not going to have much luck getting people to switch > over to SCRAM if the default remains MD5. Perhaps there should be a > GUC for this - and we can initially set that GUC to md5, allowing > people who are ready to adopt SCRAM to change it. And then in a later > release we can change the default, once we're pretty confident that > most connectors have added support for the new authentication method. > This is going to take a long time to roll out. > Alternatively, we could control it strictly through DDL. This maps quite a lot with the existing password_encryption, so adding a GUC to control only the format of protocols only for ENCRYPTED is disturbing, say password_encryption_encrypted. I'd rather keep ENCRYPTED to md5 as default when password_encryption is 'on', switch to scram a couple of releases later, and extend the DDL grammar with something like PROTOCOL {'md5' | 'plain' | 'scram'}, which can be used instead of UNENCRYPTED | ENCRYPTED as an additional keyword. Smooth transition to a more-extensive system. > Note that the existing behavior is pretty wonky: > alter user rhaas unencrypted password 'foo'; -> rolpassword foo > alter user rhaas encrypted password 'foo'; -> rolpassword > md5e748797a605a1c95f3d6b5f140b2d528 > alter user rhaas encrypted password > 'md5e748797a605a1c95f3d6b5f140b2d528'; -> rolpassword > md5e748797a605a1c95f3d6b5f140b2d528 > alter user rhaas unencrypted password > 'md5e748797a605a1c95f3d6b5f140b2d528'; -> rolpassword > md5e748797a605a1c95f3d6b5f140b2d528 I actually wrote some regression tests for that. Those are upthread as part of 0001, have for example a look at password.sql. > So basically the use of the ENCRYPTED keyword means "if it does > already seem to be the sort of MD5 blob we're expecting, turn it into > that". And we just rely on the format to distinguish between an MD5 > verifier and an unencrypted password. Personally, I think a good > start here, and I think you may have something like this in the patch > already, would be to split rolpassword into two columns, say > rolencryption and rolpassword. rolencryption says how the password > verifier is encrypted and rolpassword contains the verifier itself. The patch has something like that. And doing this split is not that complicated to be honest. Surely that would be clearer than relying on the prefix of the identifier to see if it is md5 or not. > Initially, rolencryption will be 'plain' or 'md5', but later we can > add 'scram' as another choice, or maybe it'll be more specific like > 'scram-hmac-doodad'. And then maybe introduce syntax like this: > > alter user rhaas set password 'raw-unencrypted-passwordt' using > 'verifier-method'; > alter user rhaas set password verifier 'verifier-goes-here' using > 'verifier-method'; > > That might require making verifier a key word, which would be good to > avoid. Perhaps we could use "password validator" instead? Yes, that matches what I wrote above. At this point putting that back on board and discuss it openly at PGCon is the best course of action IMO. -- Michael
pgsql-hackers by date: