Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fjPkD-0006Kt-3o for pgsql-general@arkaria.postgresql.org; Sat, 28 Jul 2018 13:58:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fjPkA-0001BT-GW for pgsql-general@arkaria.postgresql.org; Sat, 28 Jul 2018 13:58:50 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fjPk9-0001BM-GG for pgsql-general@lists.postgresql.org; Sat, 28 Jul 2018 13:58:50 +0000 Received: from aragorn.net-wizard.org ([138.201.127.29] helo=gandalf.net-wizard.org) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fjPjz-0004jI-3p for pgsql-general@postgresql.org; Sat, 28 Jul 2018 13:58:47 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.net-wizard.org (Postfix) with ESMTP id 624DE80CB0; Sat, 28 Jul 2018 15:58:36 +0200 (CEST) X-Virus-Scanned: Gentoo amavisd-new at aragorn Received: from aragorn.net-wizard.org ([127.0.0.1]) by localhost (aragorn.net-wizard.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TH0Rv_I1nD2j; Sat, 28 Jul 2018 15:58:29 +0200 (CEST) Received: from MTEC0211 (mtec-lee-dock-2-133.ethz.ch [129.132.6.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: clavadetscher@swisspug.org) by gandalf.net-wizard.org (Postfix) with ESMTPSA id 4879280CAD; Sat, 28 Jul 2018 15:58:23 +0200 (CEST) From: "Charles Clavadetscher" To: =?utf-8?Q?'=C5=81ukasz_Jarych'?= Cc: "'Melvin Davidson'" , References: <02ef01d41b3b$1e2fda60$5a8f8f20$@swisspug.org> <031b01d41b5d$dd73a880$985af980$@swisspug.org> <041201d424f0$f6faf5a0$e4f0e0e0$@swisspug.org> <042301d424f3$08142da0$183c88e0$@swisspug.org> <062101d425be$eaa4cd70$bfee6850$@swisspug.org> In-Reply-To: Subject: RE: Read only to schema Date: Sat, 28 Jul 2018 15:58:16 +0200 Message-ID: <066e01d4267b$1001e6e0$3005b4a0$@swisspug.org> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_066F_01D4268B.D391E2D0" X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQHznPPGGnJz+lyr/RH7IZtKJgF+kQJgXwL7AeXPFJoBa9x9KQGVeTgWAlMCB90CoCAK1AIFlFqZAe1Os7UCNe+kjQFM3nLtAN59h8sBpyHyBAKklb6po57mykA= Content-Language: de-ch List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multipart message in MIME format. ------=_NextPart_000_066F_01D4268B.D391E2D0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hello Jakek =20 From: =C5=81ukasz Jarych [mailto:jaryszek@gmail.com]=20 Sent: Samstag, 28. Juli 2018 14:13 To: Melvin Davidson ; pgsql-general@postgresql.org = >> PG-General Mailing List Subject: Re: Read only to schema =20 Hi Guys, =20 thank you for such advances replies and help ! You are the best! =20 I have found out that this command: =20 GRANT ALL PRIVILAGES ON ALL TABLES IN SCHEMA schema_name TO role_name;=20 =20 Be aware that granting all privilege is not necessarily the best = approach. You are granting e.g. a user the permission to create triggers = on your table that can perform actions transparently or to truncate the = table. If this is really what you want and need, well, go for it. Otherwise = restrict it to the privileges the user really needs, e.g. =20 GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA ... =20 Regards. Charles =20 is working for me.=20 =20 I will read more and try to use it properly!=20 =20 Thank you very much,=20 Best, Jacek=20 =20 =20 =20 pt., 27 lip 2018 o 17:55 Melvin Davidson > napisa=C5=82(a): Jacek,=20 you appear to be confused on how security works in PostgreSQL. Please review the options in=20 =20 https://www.postgresql.org/docs/10/static/sql-grant.html and read the Description that follows on that page As owner or superuser, you can GRANT CONNECT {CREATE} ON DATABASE; GRANT USAGE {CREATE} ON SCHEMA schema_name TO role_name; GRANT SELECT ON TABLE table_name TO role_name; GRANT SELECT ON ALL TABLES IN SCHEMA schema_name TO role_name; What you want is probably the last of these. If you are still confused, you should probably purchase=20 or download=20 PostgreSQL Administration Essentials Chapter 3: Users and Permissions from = https://www.packtpub.com/all?search=3DPostgreSQL+Administration+Essential= s = = &availability_list%5BAvailable%5D=3DAvailable&offset=3D&rows=3D&sort=3D =20 On Fri, Jul 27, 2018 at 11:31 AM, Charles Clavadetscher = > wrote: Hi =20 Please notice that in this mailing list it is not customary to top post. =20 From: =C5=81ukasz Jarych [mailto:jaryszek@gmail.com = ]=20 Sent: Freitag, 27. Juli 2018 12:19 To: Charles Clavadetscher >; pgsql-general@postgresql.org = >> PG-General Mailing List = > Subject: Re: Read only to schema =20 Hi, =20 ok i hate this.=20 =20 SELECT datname, datacl FROM pg_database where datname =3D 'AccessLog';=20 =20 \What does it mean? =20 The ACL (Access Control List) contains all the information about which = role can do what on that object, in this case a database and which role = granted the privileges. =20 You can find detailed information in the documentation: https://www.postgresql.org/docs/10/static/sql-grant.html =20 An ACL is an array of aclitem, which again is basically a key/value pair = with an equal sign between the key and the value. In this context the key is the grantee, i.e. the role being granted a = privilege. The value is the list of privileges (see list following the link above) = granted to that role, followed by a slash (/) and the role that granted = the privilege. The list of acronyms is a.o. in the link I gave above. Here for your = convenience: =20 rolename=3Dxxxx -- privileges granted to a role =3Dxxxx -- privileges granted to PUBLIC =20 r -- SELECT ("read") w -- UPDATE ("write") a -- INSERT ("append") d -- DELETE D -- TRUNCATE x -- REFERENCES t -- TRIGGER X -- EXECUTE U -- USAGE C -- CREATE c -- CONNECT T -- TEMPORARY arwdDxt -- ALL PRIVILEGES (for tables, varies for other objects) * -- grant option for preceding privilege =20 /yyyy -- role that granted this privilege =20 If the key is empty, it means that the privilege is granted to public, = i.e. every role. =20 Example: =20 admin=3DCTc/postgres means that role postgres granted Connect (c), = Create (C) and Temporary (T) to role admin. =20 Notice that the granting role may differ from the one you are using, if = you are acting as superuser: =20 =E2=80=9CIf a superuser chooses to issue a GRANT or REVOKE command, the = command is performed as though it were issued by the owner of the = affected object. In particular, privileges granted via such a command = will appear to have been granted by the object owner. (For role = membership, the membership appears to have been granted by the = containing role itself.)=E2=80=9D =20 If the ACL is empty (NULL) then the predefined default privileges apply. =