Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iiIu6-00019h-8N for pgsql-sql@arkaria.postgresql.org; Fri, 20 Dec 2019 14:05:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iiIu5-0007k1-2R for pgsql-sql@arkaria.postgresql.org; Fri, 20 Dec 2019 14:05:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iiIu4-0007jq-MO; Fri, 20 Dec 2019 14:05:16 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iiItt-0006Mx-Qp; Fri, 20 Dec 2019 14:05:14 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id xBKE4v1F002744; Fri, 20 Dec 2019 09:04:58 -0500 From: Tom Lane To: ROS Didier cc: "pgsql-hackers@postgresql.org" , "pgsql-sql@postgresql.org" Subject: Re: problem with read-only user In-reply-to: <0d4a7143cb7b4a749ca7e4603e6a795e@PCYINTPEXMU001.NEOPROD.EDF.FR> References: <0d4a7143cb7b4a749ca7e4603e6a795e@PCYINTPEXMU001.NEOPROD.EDF.FR> Comments: In-reply-to ROS Didier message dated "Fri, 20 Dec 2019 13:01:50 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2742.1576850697.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 20 Dec 2019 09:04:57 -0500 Message-ID: <2743.1576850697@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ROS Didier writes: > I created a read-only role as follows: > psql -p 5434 kidsdpn03 > CREATE ROLE kidsdpn03_ro PASSWORD 'xxx'; > ALTER ROLE kidsdpn03_ro WITH LOGIN; > GRANT CONNECT ON DATABASE kidsdpn03 TO kidsdpn03_ro; > GRANT USAGE ON SCHEMA kidsdpn03 TO kidsdpn03_ro; > GRANT SELECT ON ALL TABLES IN SCHEMA kidsdpn03 TO kidsdpn03_ro; > GRANT SELECT ON ALL SEQUENCES IN SCHEMA kidsdpn03 TO kidsdpn03_ro; > ALTER DEFAULT PRIVILEGES IN SCHEMA kidsdpn03 GRANT SELECT ON TABLES TO k= idsdpn03_ro; > ALTER ROLE kidsdpn03_ro SET search_path TO kidsdpn03; > but when i create new tables, i don't have read access to those new tab= les. = You only showed us part of what you did ... but IIRC, = ALTER DEFAULT PRIVILEGES only affects privileges for objects subsequently made by the same user that issued the command. (Otherwise it'd be a security issue.) So maybe you didn't make the tables as the same user? regards, tom lane