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 1qYs0o-002y5a-Km for pgsql-general@arkaria.postgresql.org; Wed, 23 Aug 2023 17:51:22 +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 1qYs0n-00FAqY-Es for pgsql-general@arkaria.postgresql.org; Wed, 23 Aug 2023 17:51:21 +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 1qYs0n-00FAqO-0A for pgsql-general@lists.postgresql.org; Wed, 23 Aug 2023 17:51:20 +0000 Received: from mout-u-204.mailbox.org ([80.241.59.204]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qYs0k-000cJz-9v for pgsql-general@lists.postgresql.org; Wed, 23 Aug 2023 17:51:20 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4RWDKZ0Tmkz9sSS; Wed, 23 Aug 2023 19:51:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ewie.name; s=MBO0001; t=1692813074; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pPSARJvaXi+nIpbqLxSo7RzRaQDl9OQW/CPqKKlgI3s=; b=0+AC9GNWfzMu4YP6ViOn/6SWsEYxkzytzHhjI5Gn7AwrOiscRuFcCiIylj2QPIXF8BGLqJ mN9ykwIuRrkx7lpP/QectvUwP86p+5iNndzEOCobTbaFx3NZf2+hkDhQCVykCW99JobfEz sS5zwBW/wsRSz7TcJdtK24guKJcaRZZFmf1+c7B+/+9VWLM7t1Zzr+H7r5GE0O1qzSezb3 SajDXdCa/gW6gXofHYxC8DYc1AvGzU11r9LpwiWlwShGgDiPvz0fjorrhSQws2Guh4KPHc bEnmoI/FztDvYcprH3zDwaUdz5tHpFgOQBrg/UpVpbS5DchMB+f26Hq8iPIBIA== Date: Wed, 23 Aug 2023 19:51:13 +0200 (CEST) From: Erik Wienhold To: Hellen Jiang , "pgsql-general@lists.postgresql.org" Message-ID: <2050922589.351126.1692813073578@office.mailbox.org> In-Reply-To: References: Subject: Re: Read only user permission MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Rspamd-Queue-Id: 4RWDKZ0Tmkz9sSS List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 23/08/2023 18:42 CEST Hellen Jiang wrote: > > I have created readonly and readwrite roles with the following grants: > however, readonly user does not have access to the new tables created by > readwrite user. (readonly user has the access to new tables created by admin). > Any idea how I can grant the access to readonly to make sure it has the read > access to NEW tables created by readwrite user? > > -- Read-only role > GRANT CONNECT ON DATABASE mydatabase TO readonly; > GRANT USAGE ON SCHEMA public TO dbreadonly; > GRANT SELECT ON ALL TABLES IN SCHEMA public TO dbreadonly; > GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO dbreadonly; > ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO dbreadonly; It says "dbreadonly" instead of "readonly". Just a typo or a different role? > -- Read/write role > GRANT CONNECT ON DATABASE mydatabase TO readwrite; > GRANT USAGE, CREATE ON SCHEMA public TO readwrite; > GRANT SELECT, INSERT, UPDATE, DELETE, TRUNCATE ON ALL TABLES IN SCHEMA public TO readwrite; > GRANT USAGE ON ALL SEQUENCES IN SCHEMA public TO readwrite; > ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE,TRUNCATE ON TABLES TO readwrite; > ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO readwrite; -- Erik