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 1gNkDQ-0004X2-2h for pgsql-general@arkaria.postgresql.org; Fri, 16 Nov 2018 19:55:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gNkDN-0000y8-Ts for pgsql-general@arkaria.postgresql.org; Fri, 16 Nov 2018 19:55:41 +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 1gNkDN-0000xh-Lb for pgsql-general@lists.postgresql.org; Fri, 16 Nov 2018 19:55:41 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gNkDK-0000b0-Qh for pgsql-general@lists.postgresql.org; Fri, 16 Nov 2018 19:55:41 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 7739C5F79C; Fri, 16 Nov 2018 14:55:37 -0500 (EST) Date: Fri, 16 Nov 2018 14:55:37 -0500 From: Stephen Frost To: Tom Lane Cc: Nicolas Paris , pgsql-general@lists.postgresql.org Subject: Re: Default Privilege Table ANY ROLE Message-ID: <20181116195537.GH3415@tamriel.snowman.net> References: <20181114141608.ryvolxl7v7z2grzi@riseup.net> <306e4be880a264c701be5dfa667a1e95de76e175.camel@cybertec.at> <20181114202055.a23bgy354qnmo7jn@riseup.net> <12333.1542228819@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="y0Ed1hDcWxc3B7cn" Content-Disposition: inline In-Reply-To: <12333.1542228819@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 --y0Ed1hDcWxc3B7cn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Tom Lane (tgl@sss.pgh.pa.us) wrote: > Maybe I'm missing something, but doesn't this solve your problem > as stated? >=20 > ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT SELECT ON TABLES TO pub= lic; That just means that the 'ROLE' in the result is the current role, as per the docs: ----- The name of an existing role of which the current role is a member. If FOR ROLE is omitted, the current role is assumed. ----- There was much discussion of being able to have 'FOR ALL ROLES' or similar for ALTER DEFAULT PRIVILEGES when it went in, but there was a lot of concern about one user getting to define the default privileges for objects created by some other user. The thought mentioned up-thread of having a 'group role' which can be assigned to a role and then used for the default privileges when a role creates an object seems like a neat idea, but I'm not sure how we'd deal with overlaps. Specifically: User u1, member of role r1. Role r1 has CREATE rights on schema s1. DEFAULT PRIVILEGES on schema s1 for r1 say GRANT SELECT ON TABLES TO r2. User u1 runs CREATE TABLE t1 in s1. Table t1 has GRANT SELECT ON t1 TO r2 applied. On that vein, I'd love it if table t1 was then also OWNED by r1, as that is the role which allows the CREATE to happen. The issue here though is that a given user 'u1' could have access to the schema 's1' through multiple other roles and there's no way to say which role to use, and obviously we'd want it to somehow be deterministic. If we did allow the 'FOR ALL ROLES' as suggested- who would be allowed to set that? I certainly don't want more superuser-only things, but currently a schema owner isn't allowed to set the privileges on objects in their schema on a per-object level, at least not explicitly, and we don't allow them to set DEFAULT PRIVILEGES for some other role: =3D*> alter default privileges for role r2 in schema ts grant select on tab= les to r1; ERROR: must be member of role "r2" I do think there's an argument to be made for having a default role who is explicitly allowed to set/change the privileges on objects in the system, but in an ideal world that role wouldn't be allowed to access any of the data in the system. Such a role could have this right, perhaps. Thanks! Stephen --y0Ed1hDcWxc3B7cn Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJb7yC5AAoJEO1sijiDR2RVSc0QALfWF/7lpwDRKy2qpMTi+lyn 2BtniV9Rw8tBegabi7KJCyzvXo5vY8Tozk8qlN+bzZGBYeJ6JeCWWnN9PVrwLtPf FkL2/ZKKDMnEhK2vMN37Rxc2BsiTLLotc/N67YEloPn03YR9/rRdEIBhrRTaw1nn idkIqXQgnmuhw01SgPMawUZdKG0oJrL759DrB4OjsqjX4vWEGfdnbp/oRVi9nflx witU2tU/bc0umnRuYFS5mNg7BcKAp6uRA5NxYZMvsH+UZ2sHzu7QK9n5kHptX+iw +bPB8NjZ3n5ieXCtuJC1MisLQrpM7mJKG/JkHx2LdFmfYCeJgmFgQ+6P45ZIDUru 1RzbGAuxlARsvKDBJPrzTPNSOSpR4fltgR/YKkIbCgx45r2C/LQ9DcCpT/qJVECe 1zLKLwbTD7tiF9vOMTS2/GDqzlcWgxaOpG3Trz3jDhm4b8A11V3UONtENjnaPMy2 oANniShqXPx4oNVA+vkwQCEkKGyHQrMUlL9j1ADV2WUotvJq9IfnQmIdHJHrr+zn +fCbyqqCqqz7Lm7MPF0H9lWCeMmLoMhEoHoCquGYqGbrLxkcQ+qhy/cBhkWIE1xA MNXbbPDl5JSkNsFMrJeCgGfaxcpBOxBNapjsavIe4qSJilXF125V/yr56D/2MgOT oUEqd8t9V7cdZ+bXQUvv =FNDx -----END PGP SIGNATURE----- --y0Ed1hDcWxc3B7cn--