From: Heikki Linnakangas Date: Mon, 8 May 2017 08:26:07 +0000 (+0300) Subject: Remove support for password_encryption='off' / 'plain'. X-Git-Tag: REL_10_BETA1~78 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb61136dc75a76caef8460fa939244d8593100f2;p=postgresql Remove support for password_encryption='off' / 'plain'. Storing passwords in plaintext hasn't been a good idea for a very long time, if ever. Now seems like a good time to finally forbid it, since we're messing with this in PostgreSQL 10 anyway. Remove the CREATE/ALTER USER UNENCRYPTED PASSSWORD 'foo' syntax, since storing passwords unencrypted is no longer supported. ENCRYPTED PASSWORD 'foo' is still accepted, but ENCRYPTED is now just a noise-word, it does the same as just PASSWORD 'foo'. Likewise, remove the --unencrypted option from createuser, but accept --encrypted as a no-op for backward compatibility. AFAICS, --encrypted was a no-op even before this patch, because createuser encrypted the password before sending it to the server even if --encrypted was not specified. It added the ENCRYPTED keyword to the SQL command, but since the password was already in encrypted form, it didn't make any difference. The documentation was not clear on whether that was intended or not, but it's moot now. Also, while password_encryption='on' is still accepted as an alias for 'md5', it is now marked as hidden, so that it is not listed as an accepted value in error hints, for example. That's not directly related to removing 'plain', but it seems better this way. Reviewed by Michael Paquier Discussion: https://www.postgresql.org/message-id/16e9b768-fd78-0b12-cfc1-7b6b7f238fde@iki.fi --- diff --git a/contrib/passwordcheck/passwordcheck.c b/contrib/passwordcheck/passwordcheck.c index c988bf5169..59f73a1e6b 100644 --- a/contrib/passwordcheck/passwordcheck.c +++ b/contrib/passwordcheck/passwordcheck.c @@ -39,8 +39,8 @@ extern void _PG_init(void); * * username: name of role being created or changed * password: new password (possibly already encrypted) - * password_type: PASSWORD_TYPE_PLAINTEXT or PASSWORD_TYPE_MD5 (there - * could be other encryption schemes in future) + * password_type: PASSWORD_TYPE_* code, to indicate if the password is + * in plaintext or encrypted form. * validuntil_time: password expiration time, as a timestamptz Datum * validuntil_null: true if password expiration time is NULL * diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 0b9e3002fb..20bc3c61b1 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1188,14 +1188,16 @@ include_dir 'conf.d' When a password is specified in or - without writing either ENCRYPTED - or UNENCRYPTED, this parameter determines whether the - password is to be encrypted. The default value is md5, which - stores the password as an MD5 hash. Setting this to plain stores - it in plaintext. on and off are also accepted, as - aliases for md5 and plain, respectively. Setting - this parameter to scram-sha-256 will encrypt the password - with SCRAM-SHA-256. + , this parameter determines the algorithm + to use to encrypt the password. The default value is md5, + which stores the password as an MD5 hash (on is also + accepted, as alias for md5). Setting this parameter to + scram-sha-256 will encrypt the password with SCRAM-SHA-256. + + + Note that older clients might lack support for the SCRAM authentication + mechanism, and hence not work with passwords encrypted with + SCRAM-SHA-256. diff --git a/doc/src/sgml/ref/alter_role.sgml b/doc/src/sgml/ref/alter_role.sgml index 37fcfb926c..8cd8602bc4 100644 --- a/doc/src/sgml/ref/alter_role.sgml +++ b/doc/src/sgml/ref/alter_role.sgml @@ -33,7 +33,7 @@ ALTER ROLE role_specification [ WIT | REPLICATION | NOREPLICATION | BYPASSRLS | NOBYPASSRLS | CONNECTION LIMIT connlimit - | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password' + | [ ENCRYPTED ] PASSWORD 'password' | VALID UNTIL 'timestamp' ALTER ROLE name RENAME TO new_name @@ -168,9 +168,7 @@ ALTER ROLE { role_specification | A BYPASSRLS NOBYPASSRLS CONNECTION LIMIT connlimit - PASSWORD password - ENCRYPTED - UNENCRYPTED + [ ENCRYPTED ] PASSWORD password VALID UNTIL 'timestamp' diff --git a/doc/src/sgml/ref/alter_user.sgml b/doc/src/sgml/ref/alter_user.sgml index 5962a8e166..9b8a39b376 100644 --- a/doc/src/sgml/ref/alter_user.sgml +++ b/doc/src/sgml/ref/alter_user.sgml @@ -33,7 +33,7 @@ ALTER USER role_specification [ WIT | REPLICATION | NOREPLICATION | BYPASSRLS | NOBYPASSRLS | CONNECTION LIMIT connlimit - | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password' + | [ ENCRYPTED ] PASSWORD 'password' | VALID UNTIL 'timestamp' ALTER USER name RENAME TO new_name diff --git a/doc/src/sgml/ref/create_group.sgml b/doc/src/sgml/ref/create_group.sgml index 1d5cc9b596..158617cb93 100644 --- a/doc/src/sgml/ref/create_group.sgml +++ b/doc/src/sgml/ref/create_group.sgml @@ -30,7 +30,7 @@ CREATE GROUP name [ [ WITH ] password' + | [ ENCRYPTED ] PASSWORD 'password' | VALID UNTIL 'timestamp' | IN ROLE role_name [, ...] | IN GROUP role_name [, ...] diff --git a/doc/src/sgml/ref/create_role.sgml b/doc/src/sgml/ref/create_role.sgml index 99d1c8336c..43f2303b48 100644 --- a/doc/src/sgml/ref/create_role.sgml +++ b/doc/src/sgml/ref/create_role.sgml @@ -33,7 +33,7 @@ CREATE ROLE name [ [ WITH ] connlimit - | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password' + | [ ENCRYPTED ] PASSWORD 'password' | VALID UNTIL 'timestamp' | IN ROLE role_name [, ...] | IN GROUP role_name [, ...] @@ -207,7 +207,7 @@ CREATE ROLE name [ [ WITH ] - PASSWORD password + [ ENCRYPTED ] PASSWORD password Sets the role's password. (A password is only of use for @@ -219,30 +219,18 @@ CREATE ROLE name [ [ WITH ] PASSWORD NULL. - - - - - ENCRYPTED - UNENCRYPTED - - These key words control whether the password is stored - encrypted in the system catalogs. (If neither is specified, - the default behavior is determined by the configuration - parameter .) If the - presented password string is already in MD5-encrypted or - SCRAM-encrypted format, then it is stored encrypted as-is, - regardless of whether ENCRYPTED or UNENCRYPTED - is specified (since the system cannot decrypt the specified encrypted - password string). This allows reloading of encrypted passwords + The password is always stored encrypted in the system catalogs. The + ENCRYPTED keyword has no effect, but is accepted for + backwards compatibility. The method of encryption is determined + by the configuration parameter . + If the presented password string is already in MD5-encrypted or + SCRAM-encrypted format, then it is stored as-is regardless of + password_encryption (since the system cannot decrypt + the specified encrypted password string, to encrypt it in a + different format). This allows reloading of encrypted passwords during dump/restore. - - - Note that older clients might lack support for the SCRAM - authentication mechanism. - diff --git a/doc/src/sgml/ref/create_user.sgml b/doc/src/sgml/ref/create_user.sgml index 574604f796..8a596eec9f 100644 --- a/doc/src/sgml/ref/create_user.sgml +++ b/doc/src/sgml/ref/create_user.sgml @@ -33,7 +33,7 @@ CREATE USER name [ [ WITH ] connlimit - | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password' + | [ ENCRYPTED ] PASSWORD 'password' | VALID UNTIL 'timestamp' | IN ROLE role_name [, ...] | IN GROUP role_name [, ...] diff --git a/doc/src/sgml/ref/createuser.sgml b/doc/src/sgml/ref/createuser.sgml index 4332008c68..fda77976ff 100644 --- a/doc/src/sgml/ref/createuser.sgml +++ b/doc/src/sgml/ref/createuser.sgml @@ -124,8 +124,8 @@ PostgreSQL documentation - Encrypts the user's password stored in the database. If not - specified, the default password behavior is used. + This option is obsolete but still accepted for backward + compatibility. @@ -204,17 +204,6 @@ PostgreSQL documentation - - - - - - Does not encrypt the user's password stored in the database. If - not specified, the default password behavior is used. - - - - @@ -481,11 +470,7 @@ PostgreSQL documentation In the above example, the new password isn't actually echoed when typed, but we show what was typed for clarity. As you see, the password is - encrypted before it is sent to the client. If the option - is used, the password will appear in the echoed command - (and possibly also in the server log and elsewhere), - so you don't want to use