pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel Gustafsson <dgustafsson@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: require_auth: prepare for multiple SASL mechanisms
Date: Fri, 31 Jan 2025 15:07:24 +0000
Message-ID: <E1tdsc7-004dlC-PO@gemulon.postgresql.org> (raw)

require_auth: prepare for multiple SASL mechanisms

Prior to this patch, the require_auth implementation assumed that
the AuthenticationSASL protocol message was using SCRAM-SHA-256.
In preparation for future SASL mechanisms, like OAUTHBEARER, split
the implementation into two tiers: the first checks the acceptable
AUTH_REQ_* codes, and the second checks acceptable mechanisms if
AUTH_REQ_SASL et.al are permitted.

conn->allowed_sasl_mechs contains a list of pointers to acceptable
mechanisms, and pg_SASL_init() will bail if the selected mechanism
isn't contained in this array.

Since there's only one mechansism supported right now, one branch
of the second tier cannot be exercised yet and is protected by an
Assert(false) call.  This assertion will need to be removed when
the next mechanism is added.

This patch is extracted from a larger body of work aimed at adding
support for OAUTHBEARER in libpq.

Author: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/CAOYmi+kJqzo6XsR9TEhvVfeVNQ-TyFM5LATypm9yoQVYk=4Wrw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f8d8581ed882b79b512daaa7f71ca19c8eafcaef

Modified Files
--------------
src/interfaces/libpq/fe-auth.c            |  29 +++++
src/interfaces/libpq/fe-connect.c         | 184 +++++++++++++++++++++++++++---
src/interfaces/libpq/libpq-int.h          |   2 +
src/test/authentication/t/001_password.pl |  10 ++
4 files changed, 208 insertions(+), 17 deletions(-)



Message-ID: <E1tdsc7-004dlC-PO@gemulon.postgresql.org>
Permalink:  ../E1tdsc7-004dlC-PO@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1tdsc7-004dlC-PO@gemulon.postgresql.org

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: dgustafsson@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: require_auth: prepare for multiple SASL mechanisms
  In-Reply-To: <E1tdsc7-004dlC-PO@gemulon.postgresql.org>

* 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