Remove db_user_namespace.
authorNathan Bossart
Mon, 17 Jul 2023 18:44:59 +0000 (11:44 -0700)
committerNathan Bossart
Mon, 17 Jul 2023 18:44:59 +0000 (11:44 -0700)
This feature was intended to be a temporary measure to support
per-database user names.  A better one hasn't materialized in the
~21 years since it was added, and nobody claims to be using it, so
let's just remove it.

Reviewed-by: Michael Paquier, Magnus Hagander
Discussion: https://postgr.es/m/20230630200509.GA2830328%40nathanxps13
Discussion: https://postgr.es/m/20230630215608.GD2941194%40nathanxps13

doc/src/sgml/client-auth.sgml
doc/src/sgml/config.sgml
src/backend/libpq/auth.c
src/backend/libpq/hba.c
src/backend/postmaster/postmaster.c
src/backend/utils/misc/guc_tables.c
src/backend/utils/misc/postgresql.conf.sample
src/include/libpq/pqcomm.h

index 1f2fdcb4f5e9b21f0c2a6453e182319227ffdd15..a72f80f03304476aea2cd04527c4f317407453b4 100644 (file)
@@ -1253,11 +1253,6 @@ omicron         bryanh                  guest1
        attacks.
       
 
-      
-       The md5 method cannot be used with
-       the  feature.
-      
-
       
        To ease transition from the md5 method to the newer
        SCRAM method, if md5 is specified as a method
index c50c28546de71e5dd347809f227dd1e44c61dca2..11251fa05ea9cc7554afa45b9de44ba5314f3835 100644 (file)
@@ -1188,58 +1188,6 @@ include_dir 'conf.d'
        
       
      
-
-     
-      db_user_namespace (boolean)
-      
-       db_user_namespace configuration parameter
-      
-      
-      
-       
-        This parameter enables per-database user names.  It is off by default.
-        This parameter can only be set in the postgresql.conf
-        file or on the server command line.
-       
-
-       
-        If this is on, you should create users as username@dbname.
-        When username is passed by a connecting client,
-        @ and the database name are appended to the user
-        name and that database-specific user name is looked up by the
-        server. Note that when you create users with names containing
-        @ within the SQL environment, you will need to
-        quote the user name.
-       
-
-       
-        With this parameter enabled, you can still create ordinary global
-        users.  Simply append @ when specifying the user
-        name in the client, e.g., joe@.  The @
-        will be stripped off before the user name is looked up by the
-        server.
-       
-
-       
-        db_user_namespace causes the client's and
-        server's user name representation to differ.
-        Authentication checks are always done with the server's user name
-        so authentication methods must be configured for the
-        server's user name, not the client's.  Because
-        md5 uses the user name as salt on both the
-        client and server, md5 cannot be used with
-        db_user_namespace.
-       
-
-       
-        
-         This feature is intended as a temporary measure until a
-         complete solution is found.  At that time, this option will
-         be removed.
-        
-       
-      
-     
      
      
 
index 31a4125b71f1314905d317b2800c55bf3fdeb4e4..315a24bb3f9ac05ee1d462d6252ead2d9c45fdf3 100644 (file)
@@ -873,11 +873,6 @@ CheckMD5Auth(Port *port, char *shadow_pass, const char **logdetail)
    char       *passwd;
    int         result;
 
-   if (Db_user_namespace)
-       ereport(FATAL,
-               (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
-                errmsg("MD5 authentication is not supported when \"db_user_namespace\" is enabled")));
-
    /* include the salt to use for computing the response */
    if (!pg_strong_random(md5Salt, 4))
    {
index f89f138f3c01e56c4c9e4870cddfa13fc118f3f5..5d4ddbb04daf5be4304c39c15300a8af88836e32 100644 (file)
@@ -1741,19 +1741,7 @@ parse_hba_line(TokenizedAuthLine *tok_line, int elevel)
    else if (strcmp(token->string, "reject") == 0)
        parsedline->auth_method = uaReject;
    else if (strcmp(token->string, "md5") == 0)
-   {
-       if (Db_user_namespace)
-       {
-           ereport(elevel,
-                   (errcode(ERRCODE_CONFIG_FILE_ERROR),
-                    errmsg("MD5 authentication is not supported when \"db_user_namespace\" is enabled"),
-                    errcontext("line %d of configuration file \"%s\"",
-                               line_num, file_name)));
-           *err_msg = "MD5 authentication is not supported when \"db_user_namespace\" is enabled";
-           return NULL;
-       }
        parsedline->auth_method = uaMD5;
-   }
    else if (strcmp(token->string, "scram-sha-256") == 0)
        parsedline->auth_method = uaSCRAM;
    else if (strcmp(token->string, "pam") == 0)
index 0b1de9efb27b5d2a70f9a627c0b42421fab2e072..9c8ec779f9b9d1b522885c242d352d1b558694fc 100644 (file)
@@ -236,7 +236,6 @@ int         AuthenticationTimeout = 60;
 
 bool       log_hostname;       /* for ps display and logging */
 bool       Log_connections = false;
-bool       Db_user_namespace = false;
 
 bool       enable_bonjour = false;
 char      *bonjour_name;
@@ -2272,24 +2271,6 @@ retry1:
    if (port->database_name == NULL || port->database_name[0] == '\0')
        port->database_name = pstrdup(port->user_name);
 
-   if (Db_user_namespace)
-   {
-       /*
-        * If user@, it is a global user, remove '@'. We only want to do this
-        * if there is an '@' at the end and no earlier in the user string or
-        * they may fake as a local user of another database attaching to this
-        * database.
-        */
-       if (strchr(port->user_name, '@') ==
-           port->user_name + strlen(port->user_name) - 1)
-           *strchr(port->user_name, '@') = '\0';
-       else
-       {
-           /* Append '@' and dbname */
-           port->user_name = psprintf("%s@%s", port->user_name, port->database_name);
-       }
-   }
-
    if (am_walsender)
        MyBackendType = B_WAL_SENDER;
    else
index 93dc2e768094116b4059e75702a9410523535859..f9dba43b8c08c4a9b32b0503f842b5035c69723b 100644 (file)
@@ -1545,15 +1545,6 @@ struct config_bool ConfigureNamesBool[] =
        false,
        NULL, NULL, NULL
    },
-   {
-       {"db_user_namespace", PGC_SIGHUP, CONN_AUTH_AUTH,
-           gettext_noop("Enables per-database user names."),
-           NULL
-       },
-       &Db_user_namespace,
-       false,
-       NULL, NULL, NULL
-   },
    {
        {"default_transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
            gettext_noop("Sets the default read-only status of new transactions."),
index e4c0269fa3d759d5b6370e5ca97f4d608b570577..c768af9a73bc5e38334c07837c7f5f2e42428565 100644 (file)
@@ -96,7 +96,6 @@
 #authentication_timeout = 1min     # 1s-600s
 #password_encryption = scram-sha-256   # scram-sha-256 or md5
 #scram_iterations = 4096
-#db_user_namespace = off
 
 # GSSAPI using Kerberos
 #krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
index c85090259d9d96cbb745cf5f340b7d8f8c26f9db..3da00f79839ff32fa8810bfeedcb10ce7b6634ab 100644 (file)
@@ -103,8 +103,6 @@ typedef ProtocolVersion MsgType;
 
 typedef uint32 PacketLen;
 
-extern PGDLLIMPORT bool Db_user_namespace;
-
 /*
  * In protocol 3.0 and later, the startup packet length is not fixed, but
  * we set an arbitrary limit on it anyway.  This is just to prevent simple