Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gKGlW-0005Sd-9Q for pgsql-admin@arkaria.postgresql.org; Wed, 07 Nov 2018 05:52:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gKGlS-0006r4-RO for pgsql-admin@arkaria.postgresql.org; Wed, 07 Nov 2018 05:52:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gKGlS-0006qx-J6 for pgsql-admin@lists.postgresql.org; Wed, 07 Nov 2018 05:52:30 +0000 Received: from n3.nabble.com ([162.255.23.22]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gKGlP-0004Vl-RS for pgsql-admin@postgresql.org; Wed, 07 Nov 2018 05:52:30 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id B583C10229542 for ; Tue, 6 Nov 2018 22:52:25 -0700 (MST) Date: Tue, 6 Nov 2018 22:52:25 -0700 (MST) From: pavan95 To: pgsql-admin@postgresql.org Message-ID: <1541569945694-0.post@n3.nabble.com> In-Reply-To: References: <1541419964128-0.post@n3.nabble.com> Subject: Re: How to revoke "Create Privilege" from a readonly user in postgres? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Ron, Nice to see your reply. I have done an experiment based on what you have said. And I found a constraint like the newly created objects in the schema(other than public) will not possess "SELECT"(for that matter any given privilege). And it will work after granting the privilege explicitly. Please consider the below scenarion: abc=# create schema readonly; CREATE SCHEMA abc=# create role readonly with login password 'readonly' ; CREATE ROLE abc=# grant connect on database abc to readonly; GRANT abc=#revoke all privileges on schema readonly from readonly; REVOKE abc=# grant usage on schema readonly to readonly; GRANT abc=# grant SELECT on all tables in schema readonly to readonly; GRANT Now as postgres user connected to database "abc" and created the following tables abc=# create table readonly.table1(id int); CREATE TABLE abc=# insert into readonly.table1 VALUES(1); INSERT 0 1 abc=# insert into readonly.table1 VALUES(2); INSERT 0 1 abc=# insert into readonly.table1 VALUES(3); INSERT 0 1 abc=# insert into readonly.table1 VALUES(4); INSERT 0 1 abc=# insert into readonly.table1 VALUES(5); INSERT 0 1 abc=# \q Now connected as "readonly" user to database "abc" abc=#select * from readonly.table1; ERROR: permission denied for relation table1 Now again connected as postgres user to database "abc" and issued the following grants: abc=# grant usage on schema readonly to readonly; GRANT abc=# grant SELECT on all tables in schema readonly to readonly; GRANT Now as "readonly" user : abc=#select * from readonly.table1; id ---- 1 2 3 4 5 (5 rows) Now again as "postgres" user connected to database "abc" and created another new table in schema "readonly": abc=# create table readonly.table2(id int); CREATE TABLE abc=# insert into readonly.table2 VALUES(1); INSERT 0 1 abc=# insert into readonly.table2 VALUES(2); INSERT 0 1 abc=# insert into readonly.table2 VALUES(3); INSERT 0 1 abc=# insert into readonly.table2 VALUES(4); INSERT 0 1 abc=# insert into readonly.table2 VALUES(5); INSERT 0 1 abc=# \q So for testing as "readonly" user connected to database "abc" and issued select on readonly.table2: ==#For newly created object after granting SELECT#== abc=> select * from readonly.table2; ERROR: permission denied for relation table2 ==#For old object#== abc=#select * from readonly.table1; id ---- 1 2 3 4 5 (5 rows) So it the privilege so given is not working for the newly created objects in that schema in future. In this scenario what will be the fix that can be applied? And can't we revoke write access from a user in schema PUBLIC?? Looking forward to hear from you!! Regards, Pavan -- Sent from: http://www.postgresql-archive.org/PostgreSQL-admin-f2076596.html