Re: [PoC] Federated Authn/z with OAUTHBEARER

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Antonin Houska <ah(at)cybertec(dot)at>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PoC] Federated Authn/z with OAUTHBEARER
Date: 2025-02-23 17:08:37
Message-ID: BDCDB76F-E683-440B-9480-AD9A32F161A4@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 23 Feb 2025, at 17:49, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Daniel Gustafsson <daniel(at)yesql(dot)se> writes:
>> I spent a few more hours staring at this, and ran it through a number of CI and
>> local builds, without anything showing up. Pushed to master with the first set
>> of buildfarm animals showing green builds.
>
> Coverity has a nit-pick about this:
>
> /srv/coverity/git/pgsql-git/postgresql/src/interfaces/libpq/fe-auth-oauth.c: 784 in setup_token_request()
> 778 if (!request_copy)
> 779 {
> 780 libpq_append_conn_error(conn, "out of memory");
> 781 goto fail;
> 782 }
> 783
>>>> CID 1643156: High impact quality (WRITE_CONST_FIELD)
>>>> A write to an aggregate overwrites a const-qualified field within the aggregate.
> 784 memcpy(request_copy, &request, sizeof(request));
> 785
> 786 conn->async_auth = run_user_oauth_flow;
> 787 conn->cleanup_async_auth = cleanup_user_oauth_flow;
> 788 state->async_ctx = request_copy;
> 789 }
>
> This is evidently because of the fields declared const:
>
> /* Hook inputs (constant across all calls) */
> const char *const openid_configuration; /* OIDC discovery URI */
> const char *const scope; /* required scope(s), or NULL */
>
> 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.

Thanks for the report, will fix.

> 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.

Indeed it isn't, the only explanation is that I missed it. Will fix.

--
Daniel Gustafsson

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2025-02-23 17:19:17 Re: Adding skip scan (including MDAM style range skip scan) to nbtree
Previous Message Tom Lane 2025-02-23 17:02:49 Re: Removing unneeded self joins