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 1nNCTl-0006Bt-9E for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Feb 2022 11:40:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nNCTj-0001Sy-SC for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Feb 2022 11:40:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nNCTi-0001Sm-St for pgsql-hackers@lists.postgresql.org; Thu, 24 Feb 2022 11:40:11 +0000 Received: from [64.147.123.25] (helo=wout2-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nNCTb-0007RM-UN for pgsql-hackers@postgresql.org; Thu, 24 Feb 2022 11:40:09 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id C1F093203329; Thu, 24 Feb 2022 06:39:52 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 24 Feb 2022 06:39:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; bh=6GPFOySyuZnFhie2l3ICXOv9AH86qYYy24DPYf axvh4=; b=tO8/ApDKtH4KY6Jeq66JUcZqBJ9sPiLujYHIt6TO8Z1QQ6P8VF6Pb8 8Y9F36VIsaFH63E3SL2US9Yu9Kq9hevUY8aNk+3DISYUzj7rcwh0dfn1tSc4pU36 OxSArCBuanY8OITvmbk9IrxMsIXEaqzQbWIoCruReYfThDQF/dFfq8uiSV02OJWU w/BeauY6AaA7ZRC0cnZ0kiRH3Us9rWiJk39trgW+7b7TywksJMXxTa7e8fyuu5Pa IUy5C8Etm1cBAnEIk+hSA1vTZtomVO1rX8neOUBL/4zo0JiNFPe+8D2Gyw/5goRA T6x2dwYg6kIhNfHszijQiaPfe4OacZTw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=6GPFOySyuZnFhie2l 3ICXOv9AH86qYYy24DPYfaxvh4=; b=LD3qUzNi2vOtdrwvRlMAADPjCK87O/ADF k63yCFYAV9SH4dbdpl0sABYGCkkiDNR599FYWIzedEM0vlUqDLaZXWOy4kcIHM3R /tJkADZ9gJQnYrG8ERp+CehpvPLs256Yzu73rIjoRcU2IMVhF/fn5IHj2ob5M6yh 8uRIz6Ipd+rX9pmdaJFEmL2GH0+kPMFc11HHhZtBsU6c7ZyOzuZqeliF8SWzIuBZ +JxvmNDfb+wI4NPnlvUhfdkkfNLNP6yzZMzr9NmrlpikQKkqGmyuoOTqKwxovI9K VPAIHRiZoik714tIxXUm2OD/ceIATA6poO7cDnBwFOy9jV2drRNiQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrledvgddvlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepvdegudeuhfdtueeltedtveejheeh ieevueeigeelteegleejleeiueeiheegvefhnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 24 Feb 2022 06:39:50 -0500 (EST) Date: Thu, 24 Feb 2022 20:39:48 +0900 From: Michael Paquier To: Jacob Champion Cc: "pgsql-hackers@postgresql.org" Subject: Re: [PATCH] Expose port->authn_id to extensions and triggers Message-ID: References: <793d990837ae5c06a558d58d62de9378ab525d83.camel@vmware.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="NcKslrfx5RmrqT2v" Content-Disposition: inline In-Reply-To: <793d990837ae5c06a558d58d62de9378ab525d83.camel@vmware.com> X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.25 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --NcKslrfx5RmrqT2v Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 24, 2022 at 12:15:40AM +0000, Jacob Champion wrote: > Stephen pointed out [1] that the authenticated identity that's stored > in MyProcPort can't be retrieved by extensions or triggers. Attached is > a patch that provides both a C API and a SQL function for retrieving > it. >=20 > GetAuthenticatedIdentityString() is a mouthful but I wanted to > differentiate it from the existing GetAuthenticatedUserId(); better > names welcome. It only exists as an accessor because I wasn't sure if > extensions outside of contrib were encouraged to rely on the internal > layout of struct Port. (If they can, then that call can go away > entirely.) +char * +GetAuthenticatedIdentityString(void) +{ + if (!MyProcPort || !MyProcPort->authn_id) + return NULL; + + return pstrdup(MyProcPort->authn_id); I don't quite see the additional value that this API brings as MyProcPort is directly accessible, and contrib modules like postgres_fdw and sslinfo just use that to find the data of the current backend. Cannot a module like pgaudit, through the elog hook, do its work with what we have already in place? What's the use case for a given session to be able to report back only its own authn through SQL? I could still see a use case for that at a more global level with beentrys, but it looked like there was not much interest the last time I dropped this idea. -- Michael --NcKslrfx5RmrqT2v Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmIXboQACgkQnvQgOdby QH2Mog//SNYLN3B2jgpynKK33OKoRwtaTglWJMAoIK+tuVsp9Zx8spHxx1ObLOA5 3SN/dbDLOuZb7ZTTAO/K91CJDhERit+36Ux74+YEHaCy/dYhtpFKnvoAsJnG0+6P u6NHOi1DnXdFO84OGL6e8/YDlWuZGGdH0kWEAg61DIckMjv+77Qvo0grXOYpb5Np 3MeS3D9rclDcXOYiIjMiBMDX8/2x1WyN1nYbUmujSj62R/ZrrimBs4GAjzdy5+e9 JHxOpBSNhEbOFx9Gq+rkHwhw0UOWagvdxWKjz63JkGB/FqJwu2VoxC/tZ3PSiWgd W99YyIAVWG00TE0zYk+A31hZjlkfN48mzmmC9C3PpGmFkeYvCfbapt0ou2TblBpX aqfwNsRqljMvuym9/Jn3BepO0mcdTKVmvJvDyERz3ZLRfv8UtMf3fiVEf7bXdJDz 6lWhGOpH/5MPlzOVyuGHdnHEtSbLzIMnn+vSQolG1yvgYapv3u+f43tb+yh1pV3Z 2y4nm0znvkgV26UNme6wXCfRHuaTiG03DMAhtOnBRvfncvnQUAkj01jqZH0P2ydP +Ca4lLmspkyYRmLo11isZFR6rl2Zh6vie82Sojx8/A5gAa9775cRwjXNCuLTEYpl qpp+/2OZVDOToWLt/jejulkFab3/KBk/zaCUA2CHgKjz+TAp2VY= =GnNi -----END PGP SIGNATURE----- --NcKslrfx5RmrqT2v--