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 1tmLfR-0061pF-Ef for pgsql-hackers@arkaria.postgresql.org; Sun, 23 Feb 2025 23:45:50 +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 1tmLfP-00E1G4-UL for pgsql-hackers@arkaria.postgresql.org; Sun, 23 Feb 2025 23:45:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tmLfP-00E1Fv-F9 for pgsql-hackers@lists.postgresql.org; Sun, 23 Feb 2025 23:45:47 +0000 Received: from smtp.outgoing.loopia.se ([93.188.3.37]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tmLfM-000POi-2q for pgsql-hackers@postgresql.org; Sun, 23 Feb 2025 23:45:47 +0000 Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id 9049A2A5EBD for ; Mon, 24 Feb 2025 00:45:43 +0100 (CET) Received: from s980.loopia.se (unknown [172.22.191.5]) by s807.loopia.se (Postfix) with ESMTP id 7EC252A6526; Mon, 24 Feb 2025 00:45:43 +0100 (CET) Received: from s898.loopia.se (unknown [172.22.191.6]) by s980.loopia.se (Postfix) with ESMTP id 7B63422015A7; Mon, 24 Feb 2025 00:45:43 +0100 (CET) X-Virus-Scanned: amavisd-new at amavis.loopia.se X-Spam-Flag: NO X-Spam-Score: -1.2 X-Spam-Level: X-Spam-Status: No, score=-1.2 tagged_above=-999 required=6.2 tests=[ALL_TRUSTED=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1] autolearn=disabled Authentication-Results: s898.loopia.se (amavisd-new); dkim=pass (2048-bit key) header.d=yesql.se Received: from s979.loopia.se ([172.22.191.6]) by s898.loopia.se (s898.loopia.se [172.22.190.17]) (amavisd-new, port 10024) with LMTP id YCEnVJqhckqJ; Mon, 24 Feb 2025 00:45:43 +0100 (CET) X-Loopia-Auth: user X-Loopia-User: daniel@yesql.se X-Loopia-Originating-IP: 89.255.232.193 Received: from smtpclient.apple (customer-89-255-232-193.stosn.net [89.255.232.193]) (Authenticated sender: daniel@yesql.se) by s979.loopia.se (Postfix) with ESMTPSA id C332610BC35B; Mon, 24 Feb 2025 00:45:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yesql.se; s=loopiadkim1707475645; t=1740354342; bh=oWmincGJYGbgakCs4+uz7kwfoY3Y+R16wEUGPdfidgQ=; h=From:Subject:Date:In-Reply-To:Cc:To:References; b=t1chAhbU9K5vB5ANhpBMwy7MNsb/RakTElGA+6pAe6tDnVxUCahL0PfJmJissn717 ji1wi0bx/vkE9ZeqSKPhhc6kOfDKWDdTzlJ6ShPzLuTBbENhzbELmKy+UCRMFz8fne aggijMmJAt9kNy+ShUtMKlYaVIl5cRRxBSK2/WfhVCl9PoD1G2NXRDULRG5O0ZEgAY y+s9nTSFbz47aAOpj2gY3peJ8rMFjZif5CFT1x6hDvHF7EaH6Y1kJD7psDbLDTnKLU 4s3AD1xt/9yGJROYIZlaz1qzw6umA0GcoSetO4wYRe6L5+asv/dkwwzjE9GoTKokW/ TE1nApROmbfKg== From: Daniel Gustafsson Message-Id: <3116E7C6-3580-49FC-899F-5E4727DB6CFA@yesql.se> Content-Type: multipart/mixed; boundary="Apple-Mail=_9032F6FC-A3F0-4182-97EE-09930D339D9F" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51.11.1\)) Subject: Re: [PoC] Federated Authn/z with OAUTHBEARER Date: Mon, 24 Feb 2025 00:45:32 +0100 In-Reply-To: Cc: Jacob Champion , Peter Eisentraut , Antonin Houska , PostgreSQL Hackers To: Tom Lane 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> <912516.1740329361@sss.pgh.pa.us> X-Mailer: Apple Mail (2.3776.700.51.11.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_9032F6FC-A3F0-4182-97EE-09930D339D9F Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii >> 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. The attached diff passes CI and works for me, will revisit in the morning. -- Daniel Gustafsson --Apple-Mail=_9032F6FC-A3F0-4182-97EE-09930D339D9F Content-Disposition: attachment; filename=structfixups.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="structfixups.diff" Content-Transfer-Encoding: 7bit diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index ddb3596df83..8fa0515c6a0 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -10318,21 +10318,21 @@ typedef struct _PGpromptOAuthDevice of PGoauthBearerRequest, which should be filled in by the implementation: -typedef struct _PGoauthBearerRequest +typedef struct PGoauthBearerRequest { /* Hook inputs (constant across all calls) */ - const char *const openid_configuration; /* OIDC discovery URL */ - const char *const scope; /* required scope(s), or NULL */ + const char *openid_configuration; /* OIDC discovery URL */ + const char *scope; /* required scope(s), or NULL */ /* Hook outputs */ /* Callback implementing a custom asynchronous OAuth flow. */ PostgresPollingStatusType (*async) (PGconn *conn, - struct _PGoauthBearerRequest *request, + struct PGoauthBearerRequest *request, SOCKTYPE *altsock); /* Callback to clean up custom allocations. */ - void (*cleanup) (PGconn *conn, struct _PGoauthBearerRequest *request); + void (*cleanup) (PGconn *conn, struct PGoauthBearerRequest *request); char *token; /* acquired Bearer token */ void *user; /* hook-defined allocated data */ diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index b7399dee58e..34ddfdb1831 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -745,11 +745,11 @@ typedef struct _PGpromptOAuthDevice #define SOCKTYPE int #endif -typedef struct _PGoauthBearerRequest +typedef struct PGoauthBearerRequest { /* Hook inputs (constant across all calls) */ - const char *const openid_configuration; /* OIDC discovery URI */ - const char *const scope; /* required scope(s), or NULL */ + const char *openid_configuration; /* OIDC discovery URI */ + const char *scope; /* required scope(s), or NULL */ /* Hook outputs */ @@ -770,7 +770,7 @@ typedef struct _PGoauthBearerRequest * request->token must be set by the hook. */ PostgresPollingStatusType (*async) (PGconn *conn, - struct _PGoauthBearerRequest *request, + struct PGoauthBearerRequest *request, SOCKTYPE * altsock); /* @@ -780,7 +780,7 @@ typedef struct _PGoauthBearerRequest * This is technically optional, but highly recommended, because there is * no other indication as to when it is safe to free the token. */ - void (*cleanup) (PGconn *conn, struct _PGoauthBearerRequest *request); + void (*cleanup) (PGconn *conn, struct PGoauthBearerRequest *request); /* * The hook should set this to the Bearer token contents for the --Apple-Mail=_9032F6FC-A3F0-4182-97EE-09930D339D9F--