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 1j498j-00081n-L6 for pgsql-general@arkaria.postgresql.org; Tue, 18 Feb 2020 20:06:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j498i-0003LX-4w for pgsql-general@arkaria.postgresql.org; Tue, 18 Feb 2020 20:06:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j498h-0003LP-J2 for pgsql-general@lists.postgresql.org; Tue, 18 Feb 2020 20:06:39 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1j498a-0003aP-O6 for pgsql-general@postgresql.org; Tue, 18 Feb 2020 20:06:38 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 5CE8A5F799; Tue, 18 Feb 2020 15:06:35 -0500 (EST) Date: Tue, 18 Feb 2020 15:06:35 -0500 From: Stephen Frost To: Tom Lane Cc: Marc Munro , pgsql-general@postgresql.org Subject: Re: policies and extensions Message-ID: <20200218200635.GF3195@tamriel.snowman.net> References: <1581979568.18009.18.camel@bloodnok.com> <679.1581997707@sss.pgh.pa.us> <1582044786.18009.20.camel@bloodnok.com> <6568.1582047035@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="zcu+3IhEt8GkINKK" Content-Disposition: inline In-Reply-To: <6568.1582047035@sss.pgh.pa.us> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --zcu+3IhEt8GkINKK Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Tom Lane (tgl@sss.pgh.pa.us) wrote: > Marc Munro writes: > > On Mon, 2020-02-17 at 22:48 -0500, Tom Lane wrote: > >> An RLS policy is a table "subsidiary object" so it only depends indire= ctly > >> on the extension that owns the table. >=20 > > Yep, I get that, and I see the dependency chain in the catalog.=A0 >=20 > > However an extension can create the table with or without the policy, > > and a table created by an extension without policy can later have a > > policy added, and, unless I'm missing something, the same dependency > > chain exists in either case. >=20 > > This means that I cannot tell whether the policy was added by the > > extension or not. >=20 > I can't get very excited about that, since the same argument could be > made about triggers, indexes, or rules attached to a table, but no > one has yet complained about those cases. It's fairly hard to see the > use-case where it matters, anyway. If you're attaching policies to > tables owned by an extension after-the-fact, you're modifying the > definition of an extension-owned object, which is at best really poor > practice. We say up-front that you cannot expect the extension > mechanism to track the effects of such changes. This isn't actually entirely correct because there are clear and specific cases which we support where an extension object is modified, in a manner of speaking, after the extension has been installed- and that's through the GRANT system. The entire point of pg_init_privs is to provide a way to distinguish between what the installed extension's original privileges were and what were added later, so that pg_dump can correctly dump out the delta between the two. Policies, also being part of the overall privilege system, could certainly be looked at in a similar light as being different from triggers and indexes. In particular, anything to do with the privilege system is going to have some dependency on roles and it's rather rare for an extension to define roles- instead you'd expect the extension to be installed in a 'safe' manner, with the user able to GRANT rights or enable RLS and set up policies on objects from the extension after installation to allow certain users to have access to the extension's objects. While it's not as nice a solution at the pg_init_privs system, I would be inclined to state explicitly (and perhaps even enforce) that enabling RLS or creating policies as part of an extension isn't supported, and then modify pg_dump to always dump out those attributes of extension objects if they exist. When it comes to the GRANT system, we *must* have a way for extensions to revoke access to certain types of objects because they start out not-safe (specifically, functions), but as long as we have that we can always tell extension authors and users that they can arrange to have no one have access to the extension's tables by default and they can then enable RLS and add policies after the extension is installed. Thanks, Stephen --zcu+3IhEt8GkINKK Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJeTEPKAAoJEO1sijiDR2RVn1AQAJHrIIpkC2sSJ7rupbXIqiuA F9VTUjCRe6zUUNwfWKF7llydklD8bOwQ2rH0F4+MJFfUAI5AUJSdq8gPhpXtkOMp QFTlW7Ok5YPcjd4j4OVJ35PPvyQlfTKGGVQs3+7W3TRGlkp0oUBEXitcQalxY2MR vmCGpOeIsqA7+4eV+syzIhYmmyO/pc3bjmfbEb6u/GfA86cGPIpSkN0ZefPeE1FQ sQJAsNAkOPcvujpVrvMczOIadNBsI93oTGhc2AcckHGd6s9epCO1C4ooPJuqMHOl GK//uPqXje+MA4MdqMs1f2FI2NXaAZv1BxP/q1HWgbgBnnXSQVVLlAE9R9EO0oAU 52D0N33cr4KVQSahj7bAOIKdrbBIFp+PGpQeZNscNDMxC6NnKpuQTlfBRG+Kp91c 5XJuPOc8foSyua/i6qT9rOJ1pSPj8Q/1DB1igCpr8Pp+rcTsItF1Ue6KyCWhOey6 c+ADTuX3qFYPxlH+sLaj3oy6b6iisGnA8oh/EcO9ws+ssHdbTyRbk7PmK12+vdnO cxWnyhcWJk2Y007GCybk1k3n5CLxRmnZAQ9gzxDBiB4kAX0yzi0JHnLqs8hjzv0K ua26+sau++IuSKpqImp/osJYiyRhUcY38Hbtob91ot/NHlSoKvMhZ6XYMhxvsNV0 SgTxiFqGHkhKlIF0p7lU =B6Xs -----END PGP SIGNATURE----- --zcu+3IhEt8GkINKK--