Re: [PoC] Federated Authn/z with OAUTHBEARER - Mailing list pgsql-hackers

From Jacob Champion
Subject Re: [PoC] Federated Authn/z with OAUTHBEARER
Date
Msg-id CAOYmi+m8CP=eL-FE7bMQfsBPrFDTWFaLzk6mCyfcZEjuzz1OFQ@mail.gmail.com
Whole thread Raw
In response to Re: [PoC] Federated Authn/z with OAUTHBEARER  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Sun, Feb 23, 2025 at 8:49 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> IMO, the set of cases where it's legitimate to mark individual struct
> fields as const is negligibly small, and this doesn't seem to be one
> of them.  It's not obvious to me where/how PGoauthBearerRequest
> structs are supposed to be constructed, but I find it hard to believe
> that they will all spring full-grown from the forehead of Zeus.
> Nonetheless, this declaration requires exactly that.

As read-only inputs to the client API, they're not meant to be changed
for the lifetime of the struct (and the lifetime of the client flow).
The only place to initialize such a struct is directly above this
code.

> (I'm kind of surprised that we're not getting similar bleats from
> any buildfarm animals, but so far I don't see any.)

Is there a reason for compilers to complain? memcpy's the way I know
of to put a const-member struct on the heap, but maybe there are other
ways that don't annoy Coverity?

If the cost of this warning is too high, removing the const
declarations isn't the end of the world. But we use unconstify and
other type-punning copies in so many other places that this didn't
seem all that bad for the goal of helping out the client writer.

> BTW, as another nitpicky style matter: why do PGoauthBearerRequest
> etc. spell their struct tag names differently from their typedef names
> (that is, with/without an underscore)?  That is not our project style
> anywhere else, and I'm failing to detect a good reason to do it here.

This underscore pattern was copied directly from PQconninfoOption and
PQprintOpt.

Thanks,
--Jacob



pgsql-hackers by date:

Previous
From: Jacob Champion
Date:
Subject: Re: [PoC] Federated Authn/z with OAUTHBEARER
Next
From: Jacob Champion
Date:
Subject: Re: [PoC] Federated Authn/z with OAUTHBEARER