mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Add libpq connection parameter "scram_channel_binding"
This parameter can be used to enforce the channel binding type used during a SCRAM authentication. This can be useful to check code paths where an invalid channel binding type is used by a client and will be even more useful to allow testing other channel binding types when they are added. The default value is tls-unique, which is what RFC 5802 specifies. Clients can optionally specify an empty value, which has as effect to not use channel binding and use SCRAM-SHA-256 as chosen SASL mechanism. More tests for SCRAM and channel binding are added to the SSL test suite. Author: Author: Michael Paquier <michael.paquier@gmail.com>
This commit is contained in:
@ -71,6 +71,7 @@ static int ldapServiceLookup(const char *purl, PQconninfoOption *options,
|
||||
#endif
|
||||
|
||||
#include "common/ip.h"
|
||||
#include "common/scram-common.h"
|
||||
#include "mb/pg_wchar.h"
|
||||
#include "port/pg_bswap.h"
|
||||
|
||||
@ -122,6 +123,7 @@ static int ldapServiceLookup(const char *purl, PQconninfoOption *options,
|
||||
#define DefaultOption ""
|
||||
#define DefaultAuthtype ""
|
||||
#define DefaultTargetSessionAttrs "any"
|
||||
#define DefaultSCRAMChannelBinding SCRAM_CHANNEL_BINDING_TLS_UNIQUE
|
||||
#ifdef USE_SSL
|
||||
#define DefaultSSLMode "prefer"
|
||||
#else
|
||||
@ -262,6 +264,11 @@ static const internalPQconninfoOption PQconninfoOptions[] = {
|
||||
"TCP-Keepalives-Count", "", 10, /* strlen(INT32_MAX) == 10 */
|
||||
offsetof(struct pg_conn, keepalives_count)},
|
||||
|
||||
{"scram_channel_binding", NULL, DefaultSCRAMChannelBinding, NULL,
|
||||
"SCRAM-Channel-Binding", "D",
|
||||
21, /* sizeof("tls-server-end-point") == 21 */
|
||||
offsetof(struct pg_conn, scram_channel_binding)},
|
||||
|
||||
/*
|
||||
* ssl options are allowed even without client SSL support because the
|
||||
* client can still handle SSL modes "disable" and "allow". Other
|
||||
@ -3469,6 +3476,8 @@ freePGconn(PGconn *conn)
|
||||
free(conn->keepalives_interval);
|
||||
if (conn->keepalives_count)
|
||||
free(conn->keepalives_count);
|
||||
if (conn->scram_channel_binding)
|
||||
free(conn->scram_channel_binding);
|
||||
if (conn->sslmode)
|
||||
free(conn->sslmode);
|
||||
if (conn->sslcert)
|
||||
|
Reference in New Issue
Block a user