Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tmFAa-005Cpk-PB for pgsql-hackers@arkaria.postgresql.org; Sun, 23 Feb 2025 16:49:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tmFAY-00BbUG-NA for pgsql-hackers@arkaria.postgresql.org; Sun, 23 Feb 2025 16:49:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tmFAY-00BbU8-DM for pgsql-hackers@lists.postgresql.org; Sun, 23 Feb 2025 16:49:30 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tmFAV-000KH2-0M for pgsql-hackers@postgresql.org; Sun, 23 Feb 2025 16:49:29 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 51NGnLXp912517; Sun, 23 Feb 2025 11:49:21 -0500 From: Tom Lane To: Daniel Gustafsson cc: Jacob Champion , Peter Eisentraut , Antonin Houska , PostgreSQL Hackers Subject: Re: [PoC] Federated Authn/z with OAUTHBEARER In-reply-to: <13F329B6-86BC-40A5-96F4-102784A0357A@yesql.se> References: <6bde5f56-9e7a-4148-b81c-eb6532cb3651@eisentraut.org> <9B417838-B872-453D-BBFB-99FA957EB723@yesql.se> <54c008ad-1c23-47d8-ba6c-bed98a39c31c@eisentraut.org> <06102deb-00ef-431d-a3ea-65afb24! 6700a@eisentraut.org> <39A09EC8-2D72-4130-8C3E-8F3D1CC69A12@yesql.se> <55EA9E76-9866-486C-9C7F-C5E8B071C50E@yesql.se> <35CBB6AD-B847-4C26-9A7B-019279F280C8@yesql.se> <9F184CFE-ED8D-4B86-9529-F07821108C93@yesql.se> <83C44AB4-24B0-437F-B139-B5CBC5821BB1@yesql.se> <2A1511A0-C04B-47E4-B1C3-54C2A1C765B8@yesql.se> <13F329B6-86BC-40A5-96F4-102784A0357A@yesql.se> Comments: In-reply-to Daniel Gustafsson message dated "Thu, 20 Feb 2025 17:29:58 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <912515.1740329361.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 23 Feb 2025 11:49:21 -0500 Message-ID: <912516.1740329361@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Daniel Gustafsson 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 fi= rst 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 =3D run_user_oauth_flow; 787 conn->cleanup_async_auth =3D cleanup_user_oauth_flow; 788 state->async_ctx =3D 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. 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. (I'm kind of surprised that we're not getting similar bleats from any buildfarm animals, but so far I don't see any.) 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. regards, tom lane