Re: Password identifiers, protocol aging and SCRAM protocol
Michael Paquier <michael.paquier@gmail.com>
From: Michael Paquier <michael.paquier@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: David Steele <david@pgmasters.net>, Robert Haas <robertmhaas@gmail.com>, David Fetter <david@fetter.org>, Alvaro Herrera <alvherre@2ndquadrant.com>, Magnus Hagander <magnus@hagander.net>,
Peter Eisentraut <peter.eisentraut@2ndquadrant.com>, Heikki Linnakangas <hlinnaka@iki.fi>,
Julian Markwort <julian.markwort@uni-muenster.de>, Stephen Frost <sfrost@snowman.net>, PostgreSQL mailing lists <pgsql-hackers@postgresql.org>,
Valery Popov <v.popov@postgrespro.ru>
Date: 2016-07-25T08:04:17Z
Lists: pgsql-hackers
Attachments
- 0004-Move-encoding-routines-to-src-common.patch (application/x-patch) patch 0004
- 0005-Switch-password_encryption-to-a-enum.patch (application/x-patch) patch 0005
- 0006-Refactor-decision-making-of-password-encryption-into.patch (application/x-patch) patch 0006
- 0007-Create-generic-routine-to-fetch-password-and-valid-u.patch (application/x-patch) patch 0007
- 0008-Support-for-SCRAM-SHA-256-authentication-RFC-5802-an.patch (application/x-patch) patch 0008
- 0009-Add-clause-PASSWORD-val-USING-protocol-to-CREATE-ALT.patch (application/x-patch) patch 0009
- 0010-Add-regression-tests-for-passwords.patch (application/x-patch) patch 0010
- 0001-Refactor-SHA-functions-and-move-them-to-src-common.patch (application/x-patch) patch 0001
- 0002-Refactor-sendAuthRequest.patch (application/x-patch) patch 0002
- 0003-Refactor-RandomSalt-to-handle-salts-of-different-len.patch (application/x-patch) patch 0003
On Fri, Jul 22, 2016 at 3:43 PM, Michael Paquier <michael.paquier@gmail.com> wrote: > On Fri, Jul 22, 2016 at 9:06 AM, Michael Paquier > <michael.paquier@gmail.com> wrote: >> On Fri, Jul 22, 2016 at 9:02 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote: >>> Michael Paquier <michael.paquier@gmail.com> writes: >>>> One thing about my current set of patches is that I have begun adding >>>> files from src/common/ to libpq's list of files. As that would be new >>>> I am wondering if I should avoid doing so. >>> >>> Well, it could link source files from there just as easily as from the >>> backend. Not object files, though. >> >> OK. I'll just keep things the current way then :) > > Note: I have put more energy into that and I think that I will be able > to publish a new patch set pretty soon, like at the beginning of next > week. Ok, here is the real deal. As discussed at PGcon, I have shaved off from the set of patches the following things: - No separate catalog pg_auth_verifier - No additional column in pg_authid to determine the password type. All the logic used check if the password string has a wanted format. We do that for MD5 now, this set does it for SCRAM. - Removal of the pg_upgrade stuff. - Removal of password_protocols, so we don't care anymore about protocol aging. In short, the SCRAM verifiers get stored in rolpassword. And here is what this set of patches does: - Implementation of SCRAM-SHA-256, and not SHA1. I have moved to the one that makes the most sense considering the current situation based on RFC 5802 and 7677. - No channel binding support. I guess that this could be added later on. - password_encryption is now an enum, and gains three values: md5, plain and scram. true => md5, false => plain for backward compatibility - Grammar of CREATE/ALTER ROLE is extended with PASSWORD val USING protocol, that's a separate patch applying on top of the core patch for SASL. I have noticed as well a couple of bugs in the previous set(s) of patches: - valid_until was not checked for SCRAM - When using ENCRYPTED or UNENCRYPTED, already encrypted password should be used as-is. The same is applied to PASSWORD USING protocol to ease dump and reload. That's actually what is used for MD5. And here is a detail of the patches: - 0001, refactoring of SHA functions into src/common. - 0002, refactoring for sendAuthRequest - 0003, Refactoring for RandomSalt to accomodate with the salt used by scram (length of 10 bytes, md5 is 4). - 0004, move encoding routines to src/common/ - 0005, make password_encryption an enum - 0006, refactor some code in CREATE/ALTER role code paths related the use of password_encryption - 0007, refactor some code to have a single routine to fetch password and valid_until from pg_authid - 0008, The core implementation of SCRAM-SHA-256, with the SASL communication protocol. if you want to use SCRAM with that, things go with password_encryption = 'scram'. - 0009, addition of PASSWORD val USING protocol - 0010. regression tests for passwords. Not sure how useful they would be. But they helped me a bit. I am adding an entry in the next CF. Comments are welcome. -- Michael
Commits
-
Support SCRAM-SHA-256 authentication (RFC 5802 and 7677).
- 818fd4a67d61 10.0 landed
-
Refactor SHA2 functions and move them to src/common/.
- 273c458a2b3a 10.0 landed
-
Replace isMD5() with a more future-proof way to check if pw is encrypted.
- dbd69118c05d 10.0 landed
-
Remove bogus notice that older clients might not work with MD5 passwords.
- 7e3ae5455948 9.2.20 landed
- 470af1f41c8b 9.3.16 landed
- ada2cdb61015 9.4.11 landed
- 65a7f190b253 9.5.6 landed
- 7546c135dc30 9.6.2 landed
- 31c54096a18f 10.0 landed
-
Refactor the code for verifying user's password.
- e7f051b8f9a6 10.0 landed
-
Replace PostmasterRandom() with a stronger source, second attempt.
- fe0a0b5993df 10.0 landed
-
Remove support for (insecure) crypt authentication.
- 53a5026b5cb3 8.4.0 cited