-
+
Client Authentication
+
+ include_realm
+
+ Include the realm name from the authenticated user principal. This is useful
+ in combination with Username maps (See
+ for details), especially with regular expressions, to map users from
+ multiple realms.
+
+
+
+
krb_realm
+
+ include_realm
+
+ Include the realm name from the authenticated user principal. This is useful
+ in combination with Username maps (See
+ for details), especially with regular expressions, to map users from
+ multiple realms.
+
+
+
+
krb_realm
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.176 2009/01/07 12:38:11 mha Exp $
+ * $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.177 2009/01/07 13:09:21 mha Exp $
*
*-------------------------------------------------------------------------
*/
cp = strchr(kusername, '@');
if (cp)
{
- *cp = '\0';
+ /*
+ * If we are not going to include the realm in the username that is passed
+ * to the ident map, destructively modify it here to remove the realm. Then
+ * advance past the separator to check the realm.
+ */
+ if (!port->hba->include_realm)
+ *cp = '\0';
cp++;
if (realmmatch != NULL && strlen(realmmatch))
{
char *cp = strchr(gbuf.value, '@');
- *cp = '\0';
+ /*
+ * If we are not going to include the realm in the username that is passed
+ * to the ident map, destructively modify it here to remove the realm. Then
+ * advance past the separator to check the realm.
+ */
+ if (!port->hba->include_realm)
+ *cp = '\0';
cp++;
if (realmmatch != NULL && strlen(realmmatch))
/*
* We have the username (without domain/realm) in accountname, compare to
* the supplied value. In SSPI, always compare case insensitive.
+ *
+ * If set to include realm, append it in @ format.
*/
- return check_usermap(port->hba->usermap, port->user_name, accountname, true);
+ if (port->hba->include_realm)
+ {
+ char *namebuf;
+ int retval;
+
+ namebuf = palloc(strlen(accountname) + strlen(domainname) + 2);
+ sprintf(namebuf, "%s@%s", accountname, domainname);
+ retval = check_usermap(port->hba->usermap, port->user_name, namebuf, true);
+ pfree(namebuf);
+ return retval;
+ }
+ else
+ return check_usermap(port->hba->usermap, port->user_name, accountname, true);
}
#endif /* ENABLE_SSPI */
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.179 2009/01/07 12:38:11 mha Exp $
+ * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.180 2009/01/07 13:09:21 mha Exp $
*
*-------------------------------------------------------------------------
*/
INVALID_AUTH_OPTION("krb_realm", "krb5, gssapi and sspi");
parsedline->krb_realm = pstrdup(c);
}
+ else if (strcmp(token, "include_realm") == 0)
+ {
+ if (parsedline->auth_method != uaKrb5 &&
+ parsedline->auth_method != uaGSS &&
+ parsedline->auth_method != uaSSPI)
+ INVALID_AUTH_OPTION("include_realm", "krb5, gssapi and sspi");
+ if (strcmp(c, "1") == 0)
+ parsedline->include_realm = true;
+ else
+ parsedline->include_realm = false;
+ }
else
{
ereport(LOG,
* Interface to hba.c
*
*
- * $PostgreSQL: pgsql/src/include/libpq/hba.h,v 1.54 2009/01/07 12:38:11 mha Exp $
+ * $PostgreSQL: pgsql/src/include/libpq/hba.h,v 1.55 2009/01/07 13:09:21 mha Exp $
*
*-------------------------------------------------------------------------
*/
bool clientcert;
char *krb_server_hostname;
char *krb_realm;
+ bool include_realm;
} HbaLine;
typedef struct Port hbaPort;