diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2021-03-29 15:31:22 -0400 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2021-03-29 15:49:39 -0400 |
commit | 6d7a6feac48b1970c4cd127ee65d4c487acbb5e9 (patch) | |
tree | 8728162431269b3ae654eddb1d3a8e1c99972ec3 /src/include/libpq | |
parent | efcc7572f532ea564fedc6359c2df43045ee7908 (diff) | |
download | postgresql-6d7a6feac48b1970c4cd127ee65d4c487acbb5e9.tar.gz |
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
Diffstat (limited to 'src/include/libpq')
-rw-r--r-- | src/include/libpq/hba.h | 7 | ||||
-rw-r--r-- | src/include/libpq/libpq-be.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/include/libpq/hba.h b/src/include/libpq/hba.h index 8f09b5638f..1ec8603da7 100644 --- a/src/include/libpq/hba.h +++ b/src/include/libpq/hba.h @@ -71,6 +71,12 @@ typedef enum ClientCertMode clientCertFull } ClientCertMode; +typedef enum ClientCertName +{ + clientCertCN, + clientCertDN +} ClientCertName; + typedef struct HbaLine { int linenumber; @@ -101,6 +107,7 @@ typedef struct HbaLine char *ldapprefix; char *ldapsuffix; ClientCertMode clientcert; + ClientCertName clientcertname; char *krb_realm; bool include_realm; bool compat_realm; diff --git a/src/include/libpq/libpq-be.h b/src/include/libpq/libpq-be.h index 891394b0c3..713c34fedd 100644 --- a/src/include/libpq/libpq-be.h +++ b/src/include/libpq/libpq-be.h @@ -195,6 +195,7 @@ typedef struct Port */ bool ssl_in_use; char *peer_cn; + char *peer_dn; bool peer_cert_valid; /* |