Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nP2f5-0003Tp-Uy for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Mar 2022 13:35:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nP2f4-0006Tg-QS for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Mar 2022 13:35:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nP2f4-0006TX-Gj for pgsql-hackers@lists.postgresql.org; Tue, 01 Mar 2022 13:35:30 +0000 Received: from tamriel.snowman.net ([70.109.60.50]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nP2f2-0007lZ-DR for pgsql-hackers@postgresql.org; Tue, 01 Mar 2022 13:35:30 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id BE5215F7A2; Tue, 1 Mar 2022 08:35:27 -0500 (EST) Date: Tue, 1 Mar 2022 08:35:27 -0500 From: Stephen Frost To: Michael Paquier Cc: Jacob Champion , "andres@anarazel.de" , "rjuju123@gmail.com" , "pgsql-hackers@postgresql.org" Subject: Re: [PATCH] Expose port->authn_id to extensions and triggers Message-ID: <20220301133527.GS10577@tamriel.snowman.net> References: <2e28b12b450f247d5c0994207030c862263e0297.camel@vmware.com> <20220224171538.jbf2cxzmhiwuinp4@jrouhaud> <20220225212349.gf76klktl4dmm5ah@alap3.anarazel.de> <0cead4e58257beebb96f162507151271ff2f7b54.camel@vmware.com> <20220228210036.GN10577@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="nqr+Djj1aAiKpg5f" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --nqr+Djj1aAiKpg5f Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Michael Paquier (michael@paquier.xyz) wrote: > On Mon, Feb 28, 2022 at 04:00:36PM -0500, Stephen Frost wrote: > > * Jacob Champion (pchampion@vmware.com) wrote: > >> On Fri, Feb 25, 2022 at 01:23:49PM -0800, Andres Freund wrote: > >>> Looks to me like authn_id isn't synchronized to parallel workers righ= t now. So > >>> the function will return the wrong thing when executed as part of a p= arallel > >>> query. > >>=20 > >> Thanks for the catch. It looks like MyProcPort is left empty, and other > >> functions that rely on like inet_server_addr() are marked parallel- > >> restricted, so I've done the same in v4. > >=20 > > That's probably alright. >=20 > I'd say as well that this is right as-is. If it happens that there is > a use-case for making this parallel aware in the future, it could be > done. Now, it may be a bit weird to make parallel workers inherit the > authn ID of the parent as these did not go through authentication, no? > Letting this function being run only by the leader feels intuitive. I'm not really sure why we're arguing about this, but clearly the authn ID of the leader process is what should be used because that's the authentication under which the parallel worker is running, just as much as the effective role is the authorization. Having this be available in worker processes would certainly be good as it would allow more query plans to be considered when these functions are used. At this time, I don't think that outweighs the complications around having it and I'm not suggesting that Jacob needs to go do that, but surely it would be better. > >> Subject: [PATCH v4] Add API to retrieve authn_id from SQL > >>=20 > >> The authn_id field in MyProcPort is currently only accessible to the > >> backend itself. Add a SQL function, pg_session_authn_id(), to expose > >> the field to triggers that may want to make use of it. > >=20 > > Only did a quick look but generally looks reasonable to me. >=20 > The function and the test are fine, pgperltidy complains a bit about > the format of the tests.=20 >=20 > Ayway, this function needs to be documented. I think that you should > just add that in "Session Information Functions" in func.sgml, same > area as current_user(). The last time we talked about the authn ID, > one thing we discussed about was how to describe that in a good way to > the user, which is why the section of log_connections was reworked a > bit. And we don't have yet any references to what an authenticated > identity is in the docs. Agreed that it should be documented and that location seems reasonable to me. > There is no need to update catversion.h in the patch, committers > usually take care of that and that's an area of the code that > conflicts a lot. Yeah, best to let committers handle catversion bumps. Thanks, Stephen --nqr+Djj1aAiKpg5f Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJiHiEfAAoJEO1sijiDR2RVA0kP/jSHHGYvhaewoE41lJK20keL rBPG1q/SajCuKbXbrWXjdoiaz66/lzZF7L8RiMu/E1dZYOG0Vnpb8fdJb+Zt6U1z auYUN5ish3hgN3hPQp81NWbdvExygHsNi7HgvY4rbJOoii4BkQs2er7m5GhKiMbW yxtNUrqXTGYQxzdYZqRXCmLmmDEwb0WhNXNdI/wgFNo9pWWpw9Kv7LliuKXXPX2V m7rBbH352KGG+68JfaqOmDFvrLAnhDZR4wn86r9JigvJYIvcLUCDn5oWqHd5fkdo SJhKkyL3qPkWrROF+Raf5IFb2v0mrsl4hspQm+EVmklcNDRtm33VZI5bOq7ZElNc MJnE09bmiVFKYsyjpkljEJH53kukm0xg/VwnwXNWIv4igaYprY42QjRvUKOVKzeL 6ztJn9HgWhMg0+Xc2y4HZC7/v3Opo2LH40KYUDyBU8Vor41kdbzY7ZImisc3ogUc nJH2TmGd6dY9USknRAdFQeY/wfqKxhCx134wNZIlK4fJNg4YmifaJ5aCv1xaoxjS aScKADpMIdALR5Yw62jM7u08XEnapmbcgvZ1VlpmFiaOYSruepTJEy4VxEcIU2ux uCj4VXIqXVFeqwcbCJ9Mm6zrs/1NvKGBnF0ch10GI+89xkufPjQ3VHyd6Rvmg8lk GpOTFABnXTVWksitIZYC =zH2A -----END PGP SIGNATURE----- --nqr+Djj1aAiKpg5f--