pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Dunstan <andrew@dunslane.net>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow matching the DN of a client certificate for authentication
Date: Mon, 29 Mar 2021 19:50:04 +0000
Message-ID: <E1lQxtk-0002BR-Sy@gemulon.postgresql.org> (raw)

Allow matching the DN of a client certificate for authentication

Currently we only recognize the Common Name (CN) of a certificate's
subject to be matched against the user name. Thus certificates with
subjects '/OU=eng/CN=fred' and '/OU=sales/CN=fred' will have the same
connection rights. This patch provides an option to match the whole
Distinguished Name (DN) instead of just the CN. On any hba line using
client certificate identity, there is an option 'clientname' which can
have values of 'DN' or 'CN'. The default is 'CN', the current procedure.

The DN is matched against the RFC2253 formatted DN, which looks like
'CN=fred,OU=eng'.

This facility of probably best used in conjunction with an ident map.

Discussion: https://postgr.es/m/92e70110-9273-d93c-5913-0bccb6562740@dunslane.net

Reviewed-By: Michael Paquier, Daniel Gustafsson, Jacob Champion

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6d7a6feac48b1970c4cd127ee65d4c487acbb5e9

Modified Files
--------------
doc/src/sgml/client-auth.sgml         | 24 +++++++++++++-
src/backend/libpq/auth.c              | 34 +++++++++++++++----
src/backend/libpq/be-secure-openssl.c | 61 ++++++++++++++++++++++++++++++++---
src/backend/libpq/be-secure.c         |  5 +--
src/backend/libpq/hba.c               | 31 ++++++++++++++++++
src/include/libpq/hba.h               |  7 ++++
src/include/libpq/libpq-be.h          |  1 +
src/test/ssl/Makefile                 |  9 +++++-
src/test/ssl/client-dn.config         | 16 +++++++++
src/test/ssl/ssl/client-dn.crt        | 19 +++++++++++
src/test/ssl/ssl/client-dn.key        | 27 ++++++++++++++++
src/test/ssl/t/001_ssltests.pl        | 34 +++++++++++++++++--
src/test/ssl/t/SSLServer.pm           | 16 +++++++++
13 files changed, 266 insertions(+), 18 deletions(-)



view thread (3+ messages)  latest in thread

Message-ID: <E1lQxtk-0002BR-Sy@gemulon.postgresql.org>
Permalink:  ../E1lQxtk-0002BR-Sy@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lQxtk-0002BR-Sy@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: andrew@dunslane.net
  Subject: Re: pgsql: Allow matching the DN of a client certificate for authentication
  In-Reply-To: <E1lQxtk-0002BR-Sy@gemulon.postgresql.org>
  References: <E1lQxtk-0002BR-Sy@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