Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nqiC5-0004kO-Rh for pgsql-general@arkaria.postgresql.org; Mon, 16 May 2022 21:23:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nqiC4-0008R9-Eb for pgsql-general@arkaria.postgresql.org; Mon, 16 May 2022 21:23:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nqiC4-0008Qz-4G for pgsql-general@lists.postgresql.org; Mon, 16 May 2022 21:23:56 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nqiC0-0000sc-9w for pgsql-general@lists.postgresql.org; Mon, 16 May 2022 21:23:54 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id CC7475C0183; Mon, 16 May 2022 17:23:50 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 16 May 2022 17:23:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1652736230; x= 1652822630; bh=TsI2l15xthsXpqqyWzc7DCajA3RddyTjCCYXilArtKU=; b=p PKXpP3aRyPxZVy4MLKBuz2HAdyAyILb3ZfWezCM3knVe8mSXOmTBYTQV0BdZHffG J3AgEbIGEEIBQfjOG7XI48hCaYq7PC7wy1Eh2CffqMdl1QH79+nq8IzGVhBLBgzL yFANYIyyh/CSh1ykQEPyNqoZIQAni4xmROO3S3v97nXfMpPCHJ72Ex5DSGU87yV4 SqCeGtpbH3TEDi5REJVI8aFZMgysrpTTkJfA0bwmHOiT6fhKvCS11+S9+kf9VkqQ lGUdF5VojLfeot4uQpL6R9A12QUTMLRRcJBOXxAFMFNhxF3qA7tUSyMP1i2oUqbL Zrhq823LL+ywoQZSuv4Dg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1652736230; x=1652822630; bh=TsI2l15xthsXp qqyWzc7DCajA3RddyTjCCYXilArtKU=; b=hk53s3BTgSt9DkUgbgqE3rrG2c22F Bl4sh4fVTXwyc6Mn00tsmK7usFh+ZNAQGtQ5ADuRdB320k/jSyazoJPtC8qlEMr2 BrnulUnrcUqvudBazkYm2/fuD3M4Zp/S92uDCWxR2okwPOeyHKadNNbl/wCFLmLm +Rl9PwbpTQKuNIvMesLXJil9zeXoJX9+1OJv84GvBOZ2aAFg+Ms2CDpZj+6bboB6 +rNKZqGDnEUXXyz+6fk6TxzcSGut7oQTR+GB7SJ0DWHAPxQPSXJeQyr9os7GzAiQ 1cI4ltN3HwwDJ27GrWVZVeZk1eCTvReSsxTARdItMiWWQiBUAp7CP0KaQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrheehgdduheelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvvehfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuggftrfgrthhtvghrnhepgfevudejieduhfduieeiueektdevieeiieeghedu keeifeehgfeigeegvdevveevnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrgh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughr ihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 16 May 2022 17:23:49 -0400 (EDT) Subject: Re: Restricting user to see schema structure To: Bryn Llewellyn Cc: Neeraj M R , Tom Lane PostgreSQL , "David G. Johnston" , pgsql-general list References: <048ab2c5-ddf6-d039-3c2a-1828d8c9137b@aklaver.com> <569304.1652411286@sss.pgh.pa.us> <228E8A44-A504-4E0D-99BD-71B41812FFE2@yugabyte.com> <557fd2b6-dd2e-66ad-4920-25d173eaf10e@aklaver.com> <84B060E2-4393-4D49-AB4C-BAFCA94620F1@yugabyte.com> From: Adrian Klaver Message-ID: Date: Mon, 16 May 2022 14:23:48 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <84B060E2-4393-4D49-AB4C-BAFCA94620F1@yugabyte.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 5/16/22 2:04 PM, Bryn Llewellyn wrote: >> /adrian.klaver@aklaver.com wrote:/ >> >>> /bryn@yugabyte.com wrote:/ >>> >>>> /neerajmr12219@gmail.com wrote:/ >>>> >>>> ... >>> >>> What exactly do you mean by "have created a new user and granted >>> connection access to database"? As I understand it, there's no such >>> thing. I mentioned a simple test in my earlier email that showed that >>> any user (with no schema of its own and no granted privileges) can >>> connect to any database—and see the full metadata account of all its >>> content. I'm teaching myself to live with this. >> >> Besides the REVOKE CONNECT, it is also possible to prevent connections >> to a given database by a particular user by using settings in pg_hba.conf. > > Adrian, I have the "pg_hba.conf" unmodified that came with the "brew" PG > installation of PG Version 14.2 on my MacOS Big Sur laptop. It has just > six non-comment lines, thus: > > But that idea didn't work because, with my newly created user "joe", my > "\c postgres joe" failed with a complaint that my "pg_hba.conf" had no > entry for « user "joe", database "postgres" ». So it worked you could not connect. > > I discovered (by "drop user") that « role name "none" is reserved ». So > I added these lines: > > local   postgres        none                                    trust > host    postgres        none            127.0.0.1/32            trust > host    postgres        none            ::1/128                 trust none is not going to work per: https://www.postgresql.org/docs/current/auth-pg-hba-conf.html "user Specifies which database user name(s) this record matches. The value all specifies that it matches all users. Otherwise, this is either the name of a specific database user, or a group name preceded by +. (Recall that there is no real distinction between users and groups in PostgreSQL; a + mark really means “match any of the roles that are directly or indirectly members of this role”, while a name without a + mark matches only that specific role.) For this purpose, a superuser is only considered to be a member of a role if they are explicitly a member of the role, directly or indirectly, and not just by virtue of being a superuser. Multiple user names can be supplied by separating them with commas. A separate file containing user names can be specified by preceding the file name with @. " none is not listed as a special name. > But this goes against what the tip says. Anyway, after "revoke connect > on database postgres from joe", my "\c postgres joe" succeeded. Because as mentioned previously you did not "revoke connect on database postgres from public". -- Adrian Klaver adrian.klaver@aklaver.com