1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-30 06:01:21 +03:00

Add authentication parameters compat_realm and upn_usename for SSPI

These parameters are available for SSPI authentication only, to make
it possible to make it behave more like "normal gssapi", while
making it possible to maintain compatibility.

compat_realm is on by default, but can be turned off to make the
authentication use the full Kerberos realm instead of the NetBIOS name.

upn_username is off by default, and can be turned on to return the users
Kerberos UPN rather than the SAM-compatible name (a user in Active
Directory can have both a legacy SAM-compatible username and a new
Kerberos one. Normally they are the same, but not always)

Author: Christian Ullrich
Reviewed by: Robbie Harwood, Alvaro Herrera, me
This commit is contained in:
Magnus Hagander
2016-04-08 20:23:52 +02:00
parent cb0c8cbf31
commit 35e2e357cb
4 changed files with 178 additions and 0 deletions

View File

@@ -1293,6 +1293,17 @@ parse_hba_line(List *line, int line_num, char *raw_line)
parsedline->auth_method == uaSSPI)
parsedline->include_realm = true;
/*
* For SSPI, include_realm defaults to the SAM-compatible domain (aka
* NetBIOS name) and user names instead of the Kerberos principal name for
* compatibility.
*/
if (parsedline->auth_method == uaSSPI)
{
parsedline->compat_realm = true;
parsedline->upn_username = false;
}
/* Parse remaining arguments */
while ((field = lnext(field)) != NULL)
{
@@ -1585,6 +1596,24 @@ parse_hba_auth_opt(char *name, char *val, HbaLine *hbaline, int line_num)
else
hbaline->include_realm = false;
}
else if (strcmp(name, "compat_realm") == 0)
{
if (hbaline->auth_method != uaSSPI)
INVALID_AUTH_OPTION("compat_realm", gettext_noop("sspi"));
if (strcmp(val, "1") == 0)
hbaline->compat_realm = true;
else
hbaline->compat_realm = false;
}
else if (strcmp(name, "upn_username") == 0)
{
if (hbaline->auth_method != uaSSPI)
INVALID_AUTH_OPTION("upn_username", gettext_noop("sspi"));
if (strcmp(val, "1") == 0)
hbaline->upn_username = true;
else
hbaline->upn_username = false;
}
else if (strcmp(name, "radiusserver") == 0)
{
struct addrinfo *gai_result;