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 1j3d7b-00043W-Pz for pgsql-admin@arkaria.postgresql.org; Mon, 17 Feb 2020 09:55:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j3d7a-0004On-JX for pgsql-admin@arkaria.postgresql.org; Mon, 17 Feb 2020 09:55:22 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1j3d7a-0004Og-9t for pgsql-admin@lists.postgresql.org; Mon, 17 Feb 2020 09:55:22 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j3d7W-0005xU-EA for pgsql-admin@lists.postgresql.org; Mon, 17 Feb 2020 09:55:21 +0000 Received: by mail-wr1-x432.google.com with SMTP id n10so16922980wrm.1 for ; Mon, 17 Feb 2020 01:55:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=Gmu/qVqHUmTgPhZsYcobjIG64VWoKHjpBzkmQd8qPbE=; b=1BRaUChcWlUFHKISpFDK3YfqJ+LdDJ6vM97GqO3EvZ8qDQ0pEpYfLSBYbzNf1I3Lb2 Gt+dmwL/+ajP3Quez8xPGb+NZZc9a3XCiZgCLhwMA+h2hHhbVkgrlCjwDPhTJzPNa5RQ Nvs0pWEXSWSrwVvA/NEBjOmUtrK30TvpVAivlrS+OVsz0+dzdrOFaE+o0TqBAU2Vjc8N qTL+vrGwG5Izdsa5MUH5zrD1Y7LT2FsMu/Y2QWM7VDkGrKIawna7c+kq+8g/HOqs2bzN I6bk6KcMGonlQ39IFVKwVGvgj4jPSMV6kN/121mMUvHdN8Ckd2XSZBw1/Mt/B3TwQ1SE rdKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=Gmu/qVqHUmTgPhZsYcobjIG64VWoKHjpBzkmQd8qPbE=; b=qiAiKuyBO7auPxm/52FbLCP7CgT3+h2TbNCuBFwi4DOMrfdZ+yYI79edWtv4SME7+z 8Kd39ST/Afc52BPC5lW35GRaFa4xK67fkXK08EZYNMDLh2z2LVK04L4nf5kjy089hAmj jA3XR8WwKBpE+zoLV7EWaDpBCnwXZZuB91SukZVzXqF4pkJBWRzlIx3XWhJng7k7f5oe jTfPGiycYjISopoV+HXhAtuFUl7TD7ToGUGXNaHEbX8e6Z/leC/LoPUY4hcZ4pmUD0MP b3EN+ATtL8oUDFzGZ7iSZg6kHBm/c1XkLmdCzzK9LDOSKUryw5bE793qV40MMa7pHzBb J3lg== X-Gm-Message-State: APjAAAUCm9/uzpnlgg5v5+EaRB5VagizzATmOWy7dDuM4xWdPQImmeSA X0TbsUey2WsC83bLGQ0mgTf6qJ41M8o= X-Google-Smtp-Source: APXvYqykWhq9K1bl2JUY8uflq+994epU2uSpi7jjtgOrO/bOB9m5fepqzAdPufZIOELAV4NQzVe2jA== X-Received: by 2002:a5d:61cf:: with SMTP id q15mr20633112wrv.74.1581933317106; Mon, 17 Feb 2020 01:55:17 -0800 (PST) Received: from localhost.localdomain ([212.186.219.234]) by smtp.gmail.com with ESMTPSA id z19sm19433820wmi.43.2020.02.17.01.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 01:55:16 -0800 (PST) Message-ID: <4471f7658b0b352d5a5c69a881d04273053ade45.camel@cybertec.at> Subject: Re: Role Permissions are not inherited to the new objects From: Laurenz Albe To: Rajin Raj , pgsql-admin@lists.postgresql.org Date: Mon, 17 Feb 2020 10:55:16 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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