Refactor SASL code with a generic interface for its mechanisms
authorMichael Paquier <michael@paquier.xyz>
Wed, 7 Jul 2021 01:55:15 +0000 (10:55 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 7 Jul 2021 01:55:15 +0000 (10:55 +0900)
commit9fd85570d179f10f93344d722005f7086b3c31ca
treea678636aee49619b4e69f45a67df6f9498d59104
parent955b3e0f9269639fb916cee3dea37aee50b82df0
Refactor SASL code with a generic interface for its mechanisms

The code of SCRAM and SASL have been tightly linked together since SCRAM
exists in the core code, making hard to apprehend the addition of new
SASL mechanisms, but these are by design different facilities, with
SCRAM being an option for SASL.  This refactors the code related to both
so as the backend and the frontend use a set of callbacks for SASL
mechanisms, documenting while on it what is expected by anybody adding a
new SASL mechanism.

The separation between both layers is neat, using two sets of callbacks
for the frontend and the backend to mark the frontier between both
facilities.  The shape of the callbacks is now directly inspired from
the routines used by SCRAM, so the code change is straight-forward, and
the SASL code is moved into its own set of files.  These will likely
change depending on how and if new SASL mechanisms get added in the
future.

Author: Jacob Champion
Reviewed-by: Michael Paquier
Discussion: https://postgr.es/m/3d2a6f5d50e741117d6baf83eb67ebf1a8a35a11.camel@vmware.com
14 files changed:
src/backend/libpq/Makefile
src/backend/libpq/auth-sasl.c [new file with mode: 0644]
src/backend/libpq/auth-scram.c
src/backend/libpq/auth.c
src/include/libpq/auth.h
src/include/libpq/sasl.h [new file with mode: 0644]
src/include/libpq/scram.h
src/interfaces/libpq/fe-auth-sasl.h [new file with mode: 0644]
src/interfaces/libpq/fe-auth-scram.c
src/interfaces/libpq/fe-auth.c
src/interfaces/libpq/fe-auth.h
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/libpq-int.h
src/tools/pgindent/typedefs.list