pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Rajin Raj <rajin.raj@opsveda.com>
To: pgsql-admin@lists.postgresql.org
Subject: Re: Role Permissions are not inherited to the new objects
Date: Mon, 17 Feb 2020 10:55:16 +0100
Message-ID: <4471f7658b0b352d5a5c69a881d04273053ade45.camel@cybertec.at> (raw)
In-Reply-To: <CAOasRJaMV6Sk7QR2448v1bqNKPgQsK4kt61N0q9ODj8wxDCx4g@mail.gmail.com>
References: <CAOasRJaMV6Sk7QR2448v1bqNKPgQsK4kt61N0q9ODj8wxDCx4g@mail.gmail.com>

On Mon, 2020-02-17 at 14:24 +0530, Rajin Raj wrote:
> Permissions are not inherited to the new objects. I have followed the below steps,
>  
> 1. Created a new role "user_role";
> 2. Created a new schema "test_schema";
> 3. Granted SELECT ON ALL TABLES IN SCHEMA "test_schema" to "user_role";
> 4. Grant "user_role" to user_1 and user_2;
> 5. Create a new table "T1" in "test_schema" using user_1 id.
> 6. Now login with user_2 and try to query the "T1" table.
>     
>     Getting permission denied error.
>     
>     But, if I execute the grant command (step 3) after creating the table (step 4), this issue is not happening. 
>     
>     Is there any setting in pg to inherit the permissions given at top-level or refresh the permissions automatically?

To set permissions for objects created in the future, use
ALTER DEFAULT PRIVILEGES.

Be aware that you must run one ALTER DEFAULT PRIVILEGES for each
role that can create tables (keep that number low).

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






view thread (2+ messages)

Message-ID: <4471f7658b0b352d5a5c69a881d04273053ade45.camel@cybertec.at>
Permalink:  ../4471f7658b0b352d5a5c69a881d04273053ade45.camel@cybertec.at/
Also on:    postgresql.org/message-id/4471f7658b0b352d5a5c69a881d04273053ade45.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: laurenz.albe@cybertec.at, rajin.raj@opsveda.com
  Subject: Re: Role Permissions are not inherited to the new objects
  In-Reply-To: <4471f7658b0b352d5a5c69a881d04273053ade45.camel@cybertec.at>
  References: <CAOasRJaMV6Sk7QR2448v1bqNKPgQsK4kt61N0q9ODj8wxDCx4g@mail.gmail.com> <4471f7658b0b352d5a5c69a881d04273053ade45.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox