pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: Michael Paquier <michael@paquier.xyz>
Cc: Jacob Champion <pchampion@vmware.com>
Cc: andres@anarazel.de <andres@anarazel.de>
Cc: rjuju123@gmail.com <rjuju123@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: [PATCH] Expose port->authn_id to extensions and triggers
Date: Tue, 1 Mar 2022 08:35:27 -0500
Message-ID: <20220301133527.GS10577@tamriel.snowman.net> (raw)
In-Reply-To: <Yh3Czv8xFdUzFFfZ@paquier.xyz>
References: <2e28b12b450f247d5c0994207030c862263e0297.camel@vmware.com>
	<20220224171538.jbf2cxzmhiwuinp4@jrouhaud>
	<a4d9baa0717ca924331cb1dd062788bd73bd14a4.camel@vmware.com>
	<d15d02c92a3e4bdb7cc7b96b0abfe97f213e4445.camel@vmware.com>
	<cdbcf8653e56340f73438e647ea5a26f021627ed.camel@vmware.com>
	<20220225212349.gf76klktl4dmm5ah@alap3.anarazel.de>
	<Yhm9BUjrCItExUJu@paquier.xyz>
	<0cead4e58257beebb96f162507151271ff2f7b54.camel@vmware.com>
	<20220228210036.GN10577@tamriel.snowman.net>
	<Yh3Czv8xFdUzFFfZ@paquier.xyz>

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 right now. So
> >>> the function will return the wrong thing when executed as part of a parallel
> >>> query.
> >> 
> >> 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.
> > 
> > That's probably alright.
> 
> 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
> >> 
> >> 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.
> > 
> > Only did a quick look but generally looks reasonable to me.
> 
> The function and the test are fine, pgperltidy complains a bit about
> the format of the tests. 
> 
> 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

Attachments:

  signature.asc (application/pgp-signature, 818B) download

view thread (89+ messages)  latest in thread

Message-ID: <20220301133527.GS10577@tamriel.snowman.net>
Permalink:  ../20220301133527.GS10577@tamriel.snowman.net/
Also on:    postgresql.org/message-id/20220301133527.GS10577@tamriel.snowman.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: sfrost@snowman.net, michael@paquier.xyz, pchampion@vmware.com, andres@anarazel.de, rjuju123@gmail.com
  Subject: Re: [PATCH] Expose port->authn_id to extensions and triggers
  In-Reply-To: <20220301133527.GS10577@tamriel.snowman.net>
  References: <2e28b12b450f247d5c0994207030c862263e0297.camel@vmware.com> <20220224171538.jbf2cxzmhiwuinp4@jrouhaud> <a4d9baa0717ca924331cb1dd062788bd73bd14a4.camel@vmware.com> <d15d02c92a3e4bdb7cc7b96b0abfe97f213e4445.camel@vmware.com> <cdbcf8653e56340f73438e647ea5a26f021627ed.camel@vmware.com> <20220225212349.gf76klktl4dmm5ah@alap3.anarazel.de> <Yhm9BUjrCItExUJu@paquier.xyz> <0cead4e58257beebb96f162507151271ff2f7b54.camel@vmware.com> <20220228210036.GN10577@tamriel.snowman.net> <Yh3Czv8xFdUzFFfZ@paquier.xyz> <20220301133527.GS10577@tamriel.snowman.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox