pgsql: Support the same patterns for pg-user in pg_ident.conf as in pg_ - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Support the same patterns for pg-user in pg_ident.conf as in pg_
Date
Msg-id E1pIh3h-004YAn-NF@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Support the same patterns for pg-user in pg_ident.conf as in pg_hba.conf

While pg_hba.conf has support for non-literal username matches, and
this commit extends the capabilities that are supported for the
PostgreSQL user listed in an ident entry part of pg_ident.conf, with
support for:
1. The "all" keyword, where all the requested users are allowed.
2. Membership checks using the + prefix.
3. Using a regex to match against multiple roles.

1. is a feature that has been requested by Jelte Fennema, 2. something
that has been mentioned independently by Andrew Dunstan, and 3. is
something I came up with while discussing how to extend the first one,
whose implementation is facilitated by 8fea868.

This allows matching certain system users against many different
postgres users with a single line in pg_ident.conf.  Without this, one
would need one line for each of the postgres users that a system user
can log in as, which can be cumbersome to maintain.

Tests are added to the TAP test of peer authentication to provide
coverage for all that.

Note that this introduces a set of backward-incompatible changes to be
able to detect the new patterns, for the following cases:
- A role named "all".
- A role prefixed with '+' characters, which is something that would not
have worked in HBA entries anyway.
- A role prefixed by a slash character, similarly to 8fea868.
Any of these can be still be handled by using quotes in the Postgres
role defined in an ident entry.

A huge advantage of this change is that the code applies the same checks
for the Postgres roles in HBA and ident entries, via the common routine
check_role().

**This compatibility change should be mentioned in the release notes.**

Author: Jelte Fennema
Discussion: https://postgr.es/m/DBBPR83MB0507FEC2E8965012990A80D0F7FC9@DBBPR83MB0507.EURPRD83.prod.outlook.com

Branch
------
master

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

Modified Files
--------------
doc/src/sgml/client-auth.sgml         |  27 +++++-
src/backend/libpq/hba.c               |  98 ++++++++++++++-------
src/test/authentication/t/003_peer.pl | 160 ++++++++++++++++++++++++++++++++--
3 files changed, 246 insertions(+), 39 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Avoid harmless warning from pg_dump --if-exists mode.
Next
From: Amit Kapila
Date:
Subject: pgsql: Improve the description of Output Plugin Callbacks.