Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rWnFJ-007Ev0-3F for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Feb 2024 00:54:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rWnFF-009hBP-Tz for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Feb 2024 00:53:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rWnFF-009hBH-Js for pgsql-hackers@lists.postgresql.org; Mon, 05 Feb 2024 00:53:57 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rWnFC-005UsS-9W for pgsql-hackers@lists.postgresql.org; Mon, 05 Feb 2024 00:53:56 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 4150rqAw4173072; Sun, 4 Feb 2024 19:53:52 -0500 From: Tom Lane To: Graham Leggett cc: pgsql-hackers@lists.postgresql.org Subject: Re: Grant read-only access to exactly one database amongst many In-reply-to: References: Comments: In-reply-to Graham Leggett message dated "Mon, 05 Feb 2024 00:03:50 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4173070.1707094432.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 04 Feb 2024 19:53:52 -0500 Message-ID: <4173071.1707094432@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Graham Leggett writes: > Trouble is, I can create tables in db1 which is write access. I can also= connect to db2 (bad), and I can enumerate the tables in db2 (bad), althou= gh the queries of the contents say access is denied. You need to read the docs about default privileges: see about halfway down https://www.postgresql.org/docs/15/ddl-priv.html where it says "PostgreSQL grants privileges on some types of objects to PUBLIC by default ...". In this case I think you likely need to revoke the default public CREATE privilege on schema public in db1, and revoke the default public CONNECT privilege on database db2. regards, tom lane