{"kind": "auth", "major": "18", "item": {"slug": "gss", "name": "gss", "name_zh": "", "category": "Authentication and access control", "summary": "Use GSSAPI to authenticate the user. This is only available for TCP/IP connections. See Section 20.6 for details. It can be used in conjunction with GSSAPI encryption.", "aliases": [], "content_hash": "c005cdef9009c12c405513d4e8fe56d43322f357f5aba2bbe58cc441f5ada3b4", "versions": {"10": {"facts": [{"label": "Method", "value": "gss"}, {"label": "Configuration", "value": "pg_hba.conf"}, {"label": "Inventory", "value": "User-visible source authentication method"}], "tables": [{"key": "method-options", "rows": [{"name": "include_realm", "description": "If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping ( Section 20.2 ). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless krb_realm is also used. It is recommended to leave include_realm set to the default (1) and to provide an explicit mapping in pg_ident.conf to convert principal names to PostgreSQL user names."}, {"name": "map", "description": "Allows for mapping between system and database user names. See Section 20.2 for details. For a GSSAPI/Kerberos principal, such as username@EXAMPLE.COM (or, less commonly, username/hostbased@EXAMPLE.COM ), the user name used for mapping is username@EXAMPLE.COM (or username/hostbased@EXAMPLE.COM , respectively), unless include_realm has been set to 0, in which case username (or username/hostbased ) is what is seen as the system user name when mapping."}, {"name": "krb_realm", "description": "Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done."}], "title": "Documented method options and alternatives", "columns": [{"key": "name", "label": "Option or term"}, {"key": "description", "label": "Meaning"}]}], "aliases": [], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v10.23/postgresql-10.23.tar.bz2", "label": "10.23", "major": "10", "channel": "historical", "revision": "94a4b2528372458e5662c18d406629266667c437198160a18cdfd2c4a4d6eee9", "source_sha256": "94a4b2528372458e5662c18d406629266667c437198160a18cdfd2c4a4d6eee9", "catalog_fingerprint": "691be281b476dde4374d7f805b2bacc2e75bdef40f1e9d3d42e91f97fe95cfd0"}, "sources": [{"url": "https://ftp.postgresql.org/pub/source/v10.23/postgresql-10.23.tar.bz2", "label": "Matching PostgreSQL source archive", "sha256": "94a4b2528372458e5662c18d406629266667c437198160a18cdfd2c4a4d6eee9"}, {"url": "/docs/10/auth-methods.html#GSSAPI-AUTH", "path": "auth-methods.html", "label": "PostgreSQL 10 English manual", "sha256": "856d36a3fdfe8c45a25832e49bd07e9b7480f2ff9a33e58ac7c392630149bc34"}, {"url": "/docs/10/auth-pg-hba-conf.html", "path": "auth-pg-hba-conf.html", "label": "PostgreSQL 10 English manual", "sha256": "04fed609a50e8fd3013ffebb83039c544d39b6c73a6c2b2e23cd7864a70b42da"}], "sections": [], "signature": "", "attributes": {"method": "gss", "inventory": "User-visible source authentication method", "configuration": "pg_hba.conf"}, "description": ["Use GSSAPI to authenticate the user. This is only available for TCP/IP connections. See Section 20.3.3 for details."], "manual_html": "<div class=\"sect2\" id=\"GSSAPI-AUTH\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h3 class=\"title\">20.3.3.\u00a0GSSAPI Authentication</h3>\n</div>\n</div>\n</div>\n\n<p><span class=\"productname\">GSSAPI</span> is an industry-standard protocol for secure authentication defined in RFC 2743. <span class=\"productname\">PostgreSQL</span> supports <span class=\"productname\">GSSAPI</span> with <span class=\"productname\">Kerberos</span> authentication according to RFC 1964. <span class=\"productname\">GSSAPI</span> provides automatic authentication (single sign-on) for systems that support it. The authentication itself is secure, but the data sent over the database connection will be sent unencrypted unless SSL is used.</p>\n<p>GSSAPI support has to be enabled when <span class=\"productname\">PostgreSQL</span> is built; see <a class=\"xref\" href=\"/docs/10/installation.html\" title=\"Chapter\u00a016.\u00a0 Installation from Source Code\">Chapter\u00a016</a> for more information.</p>\n<p>When <span class=\"productname\">GSSAPI</span> uses <span class=\"productname\">Kerberos</span>, it uses a standard principal in the format <code class=\"literal\"><em class=\"replaceable\"><code>servicename</code></em>/<em class=\"replaceable\"><code>hostname</code></em>@<em class=\"replaceable\"><code>realm</code></em></code>. The PostgreSQL server will accept any principal that is included in the keytab used by the server, but care needs to be taken to specify the correct principal details when making the connection from the client using the <code class=\"literal\">krbsrvname</code> connection parameter. (See also <a class=\"xref\" href=\"/docs/10/libpq-connect.html#LIBPQ-PARAMKEYWORDS\" title=\"33.1.2.\u00a0Parameter Key Words\">Section\u00a033.1.2</a>.) The installation default can be changed from the default <code class=\"literal\">postgres</code> at build time using <code class=\"literal\">./configure --with-krb-srvnam=</code><em class=\"replaceable\"><code>whatever</code></em>. In most environments, this parameter never needs to be changed. Some Kerberos implementations might require a different service name, such as Microsoft Active Directory which requires the service name to be in upper case (<code class=\"literal\">POSTGRES</code>).</p>\n<p><em class=\"replaceable\"><code>hostname</code></em> is the fully qualified host name of the server machine. The service principal's realm is the preferred realm of the server machine.</p>\n<p>Client principals can be mapped to different <span class=\"productname\">PostgreSQL</span> database user names with <code class=\"filename\">pg_ident.conf</code>. For example, <code class=\"literal\">pgusername@realm</code> could be mapped to just <code class=\"literal\">pgusername</code>. Alternatively, you can use the full <code class=\"literal\">username@realm</code> principal as the role name in <span class=\"productname\">PostgreSQL</span> without any mapping.</p>\n<p><span class=\"productname\">PostgreSQL</span> also supports a parameter to strip the realm from the principal. This method is supported for backwards compatibility and is strongly discouraged as it is then impossible to distinguish different users with the same user name but coming from different realms. To enable this, set <code class=\"literal\">include_realm</code> to 0. For simple single-realm installations, doing that combined with setting the <code class=\"literal\">krb_realm</code> parameter (which checks that the principal's realm matches exactly what is in the <code class=\"literal\">krb_realm</code> parameter) is still secure; but this is a less capable approach compared to specifying an explicit mapping in <code class=\"filename\">pg_ident.conf</code>.</p>\n<p>Make sure that your server keytab file is readable (and preferably only readable, not writable) by the <span class=\"productname\">PostgreSQL</span> server account. (See also <a class=\"xref\" href=\"/docs/10/postgres-user.html\" title=\"18.1.\u00a0The PostgreSQL User Account\">Section\u00a018.1</a>.) The location of the key file is specified by the <a class=\"xref\" href=\"/docs/10/runtime-config-connection.html#GUC-KRB-SERVER-KEYFILE\">krb_server_keyfile</a> configuration parameter. The default is <code class=\"filename\">/usr/local/pgsql/etc/krb5.keytab</code> (or whatever directory was specified as <code class=\"varname\">sysconfdir</code> at build time). For security reasons, it is recommended to use a separate keytab just for the <span class=\"productname\">PostgreSQL</span> server rather than opening up permissions on the system keytab file.</p>\n<p>The keytab file is generated by the Kerberos software; see the Kerberos documentation for details. The following example is for MIT-compatible Kerberos 5 implementations:</p>\n<pre class=\"screen\"><code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>ank -randkey postgres/server.my.domain.org</code></strong>\n<code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>ktadd -k krb5.keytab postgres/server.my.domain.org</code></strong>\n</pre>\n<p>When connecting to the database make sure you have a ticket for a principal matching the requested database user name. For example, for database user name <code class=\"literal\">fred</code>, principal <code class=\"literal\">fred@EXAMPLE.COM</code> would be able to connect. To also allow principal <code class=\"literal\">fred/users.example.com@EXAMPLE.COM</code>, use a user name map, as described in <a class=\"xref\" href=\"/docs/10/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a>.</p>\n<p>The following configuration options are supported for <span class=\"productname\">GSSAPI</span>:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">include_realm</code></span></dt>\n<dd>\n<p>If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping (<a class=\"xref\" href=\"/docs/10/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a>). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless <code class=\"literal\">krb_realm</code> is also used. It is recommended to leave <code class=\"literal\">include_realm</code> set to the default (1) and to provide an explicit mapping in <code class=\"filename\">pg_ident.conf</code> to convert principal names to <span class=\"productname\">PostgreSQL</span> user names.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">map</code></span></dt>\n<dd>\n<p>Allows for mapping between system and database user names. See <a class=\"xref\" href=\"/docs/10/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a> for details. For a GSSAPI/Kerberos principal, such as <code class=\"literal\">username@EXAMPLE.COM</code> (or, less commonly, <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>), the user name used for mapping is <code class=\"literal\">username@EXAMPLE.COM</code> (or <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>, respectively), unless <code class=\"literal\">include_realm</code> has been set to 0, in which case <code class=\"literal\">username</code> (or <code class=\"literal\">username/hostbased</code>) is what is seen as the system user name when mapping.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">krb_realm</code></span></dt>\n<dd>\n<p>Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done.</p>\n</dd>\n</dl>\n</div>\n</div>", "manual_path": "/docs/10/auth-methods.html#GSSAPI-AUTH", "comparison_data": {"method": "gss", "documented_option_names": ["include_realm", "krb_realm", "map"]}, "comparison_hash": "c58b84e18bba9d75d595bab34b326eb6a8580a80636f79642c4af8843e7123cf"}, "11": {"facts": [{"label": "Method", "value": "gss"}, {"label": "Configuration", "value": "pg_hba.conf"}, {"label": "Inventory", "value": "User-visible source authentication method"}], "tables": [{"key": "method-options", "rows": [{"name": "include_realm", "description": "If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping ( Section 20.2 ). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless krb_realm is also used. It is recommended to leave include_realm set to the default (1) and to provide an explicit mapping in pg_ident.conf to convert principal names to PostgreSQL user names."}, {"name": "map", "description": "Allows for mapping between system and database user names. See Section 20.2 for details. For a GSSAPI/Kerberos principal, such as username@EXAMPLE.COM (or, less commonly, username/hostbased@EXAMPLE.COM ), the user name used for mapping is username@EXAMPLE.COM (or username/hostbased@EXAMPLE.COM , respectively), unless include_realm has been set to 0, in which case username (or username/hostbased ) is what is seen as the system user name when mapping."}, {"name": "krb_realm", "description": "Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done."}], "title": "Documented method options and alternatives", "columns": [{"key": "name", "label": "Option or term"}, {"key": "description", "label": "Meaning"}]}], "aliases": [], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v11.22/postgresql-11.22.tar.bz2", "label": "11.22", "major": "11", "channel": "historical", "revision": "2cb7c97d7a0d7278851bbc9c61f467b69c094c72b81740b751108e7892ebe1f0", "source_sha256": "2cb7c97d7a0d7278851bbc9c61f467b69c094c72b81740b751108e7892ebe1f0", "catalog_fingerprint": "8f21f4444b7f68923f4762af0eb7937fa2907026e91249483e79050de012c901"}, "sources": [{"url": "https://ftp.postgresql.org/pub/source/v11.22/postgresql-11.22.tar.bz2", "label": "Matching PostgreSQL source archive", "sha256": "2cb7c97d7a0d7278851bbc9c61f467b69c094c72b81740b751108e7892ebe1f0"}, {"url": "/docs/11/gssapi-auth.html", "path": "gssapi-auth.html", "label": "PostgreSQL 11 English manual", "sha256": "123965cdb7be25b3abcb43a1eb36ca4918913ed79859779f9bc9607bf41656fb"}, {"url": "/docs/11/auth-pg-hba-conf.html", "path": "auth-pg-hba-conf.html", "label": "PostgreSQL 11 English manual", "sha256": "5477c61a002171f5b4c462052d91231c405f39d89d825faf71e52fbae358eef7"}], "sections": [], "signature": "", "attributes": {"method": "gss", "inventory": "User-visible source authentication method", "configuration": "pg_hba.conf"}, "description": ["Use GSSAPI to authenticate the user. This is only available for TCP/IP connections. See Section 20.6 for details."], "manual_html": "<div class=\"sect1\" id=\"GSSAPI-AUTH\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h2 class=\"title\">20.6.\u00a0GSSAPI Authentication</h2>\n</div>\n</div>\n</div>\n<p><span class=\"productname\">GSSAPI</span> is an industry-standard protocol for secure authentication defined in RFC 2743. <span class=\"productname\">PostgreSQL</span> supports <span class=\"productname\">GSSAPI</span> with <span class=\"productname\">Kerberos</span> authentication according to RFC 1964. <span class=\"productname\">GSSAPI</span> provides automatic authentication (single sign-on) for systems that support it. The authentication itself is secure, but the data sent over the database connection will be sent unencrypted unless SSL is used.</p>\n<p>GSSAPI support has to be enabled when <span class=\"productname\">PostgreSQL</span> is built; see <a class=\"xref\" href=\"/docs/11/installation.html\" title=\"Chapter\u00a016.\u00a0Installation from Source Code\">Chapter\u00a016</a> for more information.</p>\n<p>When <span class=\"productname\">GSSAPI</span> uses <span class=\"productname\">Kerberos</span>, it uses a standard principal in the format <code class=\"literal\"><em class=\"replaceable\"><code>servicename</code></em>/<em class=\"replaceable\"><code>hostname</code></em>@<em class=\"replaceable\"><code>realm</code></em></code>. The PostgreSQL server will accept any principal that is included in the keytab used by the server, but care needs to be taken to specify the correct principal details when making the connection from the client using the <code class=\"literal\">krbsrvname</code> connection parameter. (See also <a class=\"xref\" href=\"/docs/11/libpq-connect.html#LIBPQ-PARAMKEYWORDS\" title=\"34.1.2.\u00a0Parameter Key Words\">Section\u00a034.1.2</a>.) The installation default can be changed from the default <code class=\"literal\">postgres</code> at build time using <code class=\"literal\">./configure --with-krb-srvnam=</code><em class=\"replaceable\"><code>whatever</code></em>. In most environments, this parameter never needs to be changed. Some Kerberos implementations might require a different service name, such as Microsoft Active Directory which requires the service name to be in upper case (<code class=\"literal\">POSTGRES</code>).</p>\n<p><em class=\"replaceable\"><code>hostname</code></em> is the fully qualified host name of the server machine. The service principal's realm is the preferred realm of the server machine.</p>\n<p>Client principals can be mapped to different <span class=\"productname\">PostgreSQL</span> database user names with <code class=\"filename\">pg_ident.conf</code>. For example, <code class=\"literal\">pgusername@realm</code> could be mapped to just <code class=\"literal\">pgusername</code>. Alternatively, you can use the full <code class=\"literal\">username@realm</code> principal as the role name in <span class=\"productname\">PostgreSQL</span> without any mapping.</p>\n<p><span class=\"productname\">PostgreSQL</span> also supports a parameter to strip the realm from the principal. This method is supported for backwards compatibility and is strongly discouraged as it is then impossible to distinguish different users with the same user name but coming from different realms. To enable this, set <code class=\"literal\">include_realm</code> to 0. For simple single-realm installations, doing that combined with setting the <code class=\"literal\">krb_realm</code> parameter (which checks that the principal's realm matches exactly what is in the <code class=\"literal\">krb_realm</code> parameter) is still secure; but this is a less capable approach compared to specifying an explicit mapping in <code class=\"filename\">pg_ident.conf</code>.</p>\n<p>Make sure that your server keytab file is readable (and preferably only readable, not writable) by the <span class=\"productname\">PostgreSQL</span> server account. (See also <a class=\"xref\" href=\"/docs/11/postgres-user.html\" title=\"18.1.\u00a0The PostgreSQL User Account\">Section\u00a018.1</a>.) The location of the key file is specified by the <a class=\"xref\" href=\"/docs/11/runtime-config-connection.html#GUC-KRB-SERVER-KEYFILE\">krb_server_keyfile</a> configuration parameter. The default is <code class=\"filename\">/usr/local/pgsql/etc/krb5.keytab</code> (or whatever directory was specified as <code class=\"varname\">sysconfdir</code> at build time). For security reasons, it is recommended to use a separate keytab just for the <span class=\"productname\">PostgreSQL</span> server rather than opening up permissions on the system keytab file.</p>\n<p>The keytab file is generated by the Kerberos software; see the Kerberos documentation for details. The following example is for MIT-compatible Kerberos 5 implementations:</p>\n<pre class=\"screen\"><code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>ank -randkey postgres/server.my.domain.org</code></strong>\n<code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>ktadd -k krb5.keytab postgres/server.my.domain.org</code></strong>\n</pre>\n<p>When connecting to the database make sure you have a ticket for a principal matching the requested database user name. For example, for database user name <code class=\"literal\">fred</code>, principal <code class=\"literal\">fred@EXAMPLE.COM</code> would be able to connect. To also allow principal <code class=\"literal\">fred/users.example.com@EXAMPLE.COM</code>, use a user name map, as described in <a class=\"xref\" href=\"/docs/11/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a>.</p>\n<p>The following configuration options are supported for <span class=\"productname\">GSSAPI</span>:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">include_realm</code></span></dt>\n<dd>\n<p>If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping (<a class=\"xref\" href=\"/docs/11/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a>). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless <code class=\"literal\">krb_realm</code> is also used. It is recommended to leave <code class=\"literal\">include_realm</code> set to the default (1) and to provide an explicit mapping in <code class=\"filename\">pg_ident.conf</code> to convert principal names to <span class=\"productname\">PostgreSQL</span> user names.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">map</code></span></dt>\n<dd>\n<p>Allows for mapping between system and database user names. See <a class=\"xref\" href=\"/docs/11/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a> for details. For a GSSAPI/Kerberos principal, such as <code class=\"literal\">username@EXAMPLE.COM</code> (or, less commonly, <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>), the user name used for mapping is <code class=\"literal\">username@EXAMPLE.COM</code> (or <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>, respectively), unless <code class=\"literal\">include_realm</code> has been set to 0, in which case <code class=\"literal\">username</code> (or <code class=\"literal\">username/hostbased</code>) is what is seen as the system user name when mapping.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">krb_realm</code></span></dt>\n<dd>\n<p>Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done.</p>\n</dd>\n</dl>\n</div>\n</div>", "manual_path": "/docs/11/gssapi-auth.html", "comparison_data": {"method": "gss", "documented_option_names": ["include_realm", "krb_realm", "map"]}, "comparison_hash": "c58b84e18bba9d75d595bab34b326eb6a8580a80636f79642c4af8843e7123cf"}, "12": {"facts": [{"label": "Method", "value": "gss"}, {"label": "Configuration", "value": "pg_hba.conf"}, {"label": "Inventory", "value": "User-visible source authentication method"}], "tables": [{"key": "method-options", "rows": [{"name": "include_realm", "description": "If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping ( Section 20.2 ). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless krb_realm is also used. It is recommended to leave include_realm set to the default (1) and to provide an explicit mapping in pg_ident.conf to convert principal names to PostgreSQL user names."}, {"name": "map", "description": "Allows mapping from client principals to database user names. See Section 20.2 for details. For a GSSAPI/Kerberos principal, such as username@EXAMPLE.COM (or, less commonly, username/hostbased@EXAMPLE.COM ), the user name used for mapping is username@EXAMPLE.COM (or username/hostbased@EXAMPLE.COM , respectively), unless include_realm has been set to 0, in which case username (or username/hostbased ) is what is seen as the system user name when mapping."}, {"name": "krb_realm", "description": "Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done."}], "title": "Documented method options and alternatives", "columns": [{"key": "name", "label": "Option or term"}, {"key": "description", "label": "Meaning"}]}], "aliases": [], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v12.22/postgresql-12.22.tar.bz2", "label": "12.22", "major": "12", "channel": "historical", "revision": "8df3c0474782589d3c6f374b5133b1bd14d168086edbc13c6e72e67dd4527a3b", "source_sha256": "8df3c0474782589d3c6f374b5133b1bd14d168086edbc13c6e72e67dd4527a3b", "catalog_fingerprint": "9f857f4ee4875f9c7de6bfc9df4b757dec8b3a0bb88eadb519c7bd267bd56149"}, "sources": [{"url": "https://ftp.postgresql.org/pub/source/v12.22/postgresql-12.22.tar.bz2", "label": "Matching PostgreSQL source archive", "sha256": "8df3c0474782589d3c6f374b5133b1bd14d168086edbc13c6e72e67dd4527a3b"}, {"url": "/docs/12/gssapi-auth.html", "path": "gssapi-auth.html", "label": "PostgreSQL 12 English manual", "sha256": "2d46945dcabedb2ca954fdacaebd3d7c59425f53db971d33d92be3ea1d6d03ea"}, {"url": "/docs/12/auth-pg-hba-conf.html", "path": "auth-pg-hba-conf.html", "label": "PostgreSQL 12 English manual", "sha256": "07e8cddcb38076c86dab95b72c4380a7a325f22401b5b7f9af5dd4931876f2cb"}], "sections": [], "signature": "", "attributes": {"method": "gss", "inventory": "User-visible source authentication method", "configuration": "pg_hba.conf"}, "description": ["Use GSSAPI to authenticate the user. This is only available for TCP/IP connections. See Section 20.6 for details. It can be used in conjunction with GSSAPI encryption."], "manual_html": "<div class=\"sect1\" id=\"GSSAPI-AUTH\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h2 class=\"title\">20.6.\u00a0GSSAPI Authentication</h2>\n</div>\n</div>\n</div>\n<p><span class=\"productname\">GSSAPI</span> is an industry-standard protocol for secure authentication defined in <a class=\"ulink\" href=\"https://datatracker.ietf.org/doc/html/rfc2743\">RFC 2743</a>. <span class=\"productname\">PostgreSQL</span> supports <span class=\"productname\">GSSAPI</span> for authentication, communications encryption, or both. <span class=\"productname\">GSSAPI</span> provides automatic authentication (single sign-on) for systems that support it. The authentication itself is secure. If <span class=\"productname\">GSSAPI</span> encryption or SSL encryption is used, the data sent along the database connection will be encrypted; otherwise, it will not.</p>\n<p>GSSAPI support has to be enabled when <span class=\"productname\">PostgreSQL</span> is built; see <a class=\"xref\" href=\"/docs/12/installation.html\" title=\"Chapter\u00a016.\u00a0Installation from Source Code\">Chapter\u00a016</a> for more information.</p>\n<p>When <span class=\"productname\">GSSAPI</span> uses <span class=\"productname\">Kerberos</span>, it uses a standard service principal (authentication identity) name in the format <code class=\"literal\"><em class=\"replaceable\"><code>servicename</code></em>/<em class=\"replaceable\"><code>hostname</code></em>@<em class=\"replaceable\"><code>realm</code></em></code>. The principal name used by a particular installation is not encoded in the <span class=\"productname\">PostgreSQL</span> server in any way; rather it is specified in the <em class=\"firstterm\">keytab</em> file that the server reads to determine its identity. If multiple principals are listed in the keytab file, the server will accept any one of them. The server's realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the server.</p>\n<p>When connecting, the client must know the principal name of the server it intends to connect to. The <em class=\"replaceable\"><code>servicename</code></em> part of the principal is ordinarily <code class=\"literal\">postgres</code>, but another value can be selected via <span class=\"application\">libpq</span>'s <a class=\"xref\" href=\"/docs/12/libpq-connect.html#LIBPQ-CONNECT-KRBSRVNAME\">krbsrvname</a> connection parameter. The <em class=\"replaceable\"><code>hostname</code></em> part is the fully qualified host name that <span class=\"application\">libpq</span> is told to connect to. The realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the client.</p>\n<p>The client will also have a principal name for its own identity (and it must have a valid ticket for this principal). To use <span class=\"productname\">GSSAPI</span> for authentication, the client principal must be associated with a <span class=\"productname\">PostgreSQL</span> database user name. The <code class=\"filename\">pg_ident.conf</code> configuration file can be used to map principals to user names; for example, <code class=\"literal\">pgusername@realm</code> could be mapped to just <code class=\"literal\">pgusername</code>. Alternatively, you can use the full <code class=\"literal\">username@realm</code> principal as the role name in <span class=\"productname\">PostgreSQL</span> without any mapping.</p>\n<p><span class=\"productname\">PostgreSQL</span> also supports mapping client principals to user names by just stripping the realm from the principal. This method is supported for backwards compatibility and is strongly discouraged as it is then impossible to distinguish different users with the same user name but coming from different realms. To enable this, set <code class=\"literal\">include_realm</code> to 0. For simple single-realm installations, doing that combined with setting the <code class=\"literal\">krb_realm</code> parameter (which checks that the principal's realm matches exactly what is in the <code class=\"literal\">krb_realm</code> parameter) is still secure; but this is a less capable approach compared to specifying an explicit mapping in <code class=\"filename\">pg_ident.conf</code>.</p>\n<p>The location of the server's keytab file is specified by the <a class=\"xref\" href=\"/docs/12/runtime-config-connection.html#GUC-KRB-SERVER-KEYFILE\">krb_server_keyfile</a> configuration parameter. For security reasons, it is recommended to use a separate keytab just for the <span class=\"productname\">PostgreSQL</span> server rather than allowing the server to read the system keytab file. Make sure that your server keytab file is readable (and preferably only readable, not writable) by the <span class=\"productname\">PostgreSQL</span> server account. (See also <a class=\"xref\" href=\"/docs/12/postgres-user.html\" title=\"18.1.\u00a0The PostgreSQL User Account\">Section\u00a018.1</a>.)</p>\n<p>The keytab file is generated using the Kerberos software; see the Kerberos documentation for details. The following example shows doing this using the <span class=\"application\">kadmin</span> tool of MIT-compatible Kerberos 5 implementations:</p>\n<pre class=\"screen\"><code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>addprinc -randkey postgres/server.my.domain.org</code></strong>\n<code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>ktadd -k krb5.keytab postgres/server.my.domain.org</code></strong>\n</pre>\n<p>The following authentication options are supported for the <span class=\"productname\">GSSAPI</span> authentication method:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">include_realm</code></span></dt>\n<dd>\n<p>If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping (<a class=\"xref\" href=\"/docs/12/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a>). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless <code class=\"literal\">krb_realm</code> is also used. It is recommended to leave <code class=\"literal\">include_realm</code> set to the default (1) and to provide an explicit mapping in <code class=\"filename\">pg_ident.conf</code> to convert principal names to <span class=\"productname\">PostgreSQL</span> user names.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">map</code></span></dt>\n<dd>\n<p>Allows mapping from client principals to database user names. See <a class=\"xref\" href=\"/docs/12/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a> for details. For a GSSAPI/Kerberos principal, such as <code class=\"literal\">username@EXAMPLE.COM</code> (or, less commonly, <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>), the user name used for mapping is <code class=\"literal\">username@EXAMPLE.COM</code> (or <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>, respectively), unless <code class=\"literal\">include_realm</code> has been set to 0, in which case <code class=\"literal\">username</code> (or <code class=\"literal\">username/hostbased</code>) is what is seen as the system user name when mapping.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">krb_realm</code></span></dt>\n<dd>\n<p>Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done.</p>\n</dd>\n</dl>\n</div>\n<p>In addition to these settings, which can be different for different <code class=\"filename\">pg_hba.conf</code> entries, there is the server-wide <a class=\"xref\" href=\"/docs/12/runtime-config-connection.html#GUC-KRB-CASEINS-USERS\">krb_caseins_users</a> configuration parameter. If that is set to true, client principals are matched to user map entries case-insensitively. <code class=\"literal\">krb_realm</code>, if set, is also matched case-insensitively.</p>\n</div>", "manual_path": "/docs/12/gssapi-auth.html", "comparison_data": {"method": "gss", "documented_option_names": ["include_realm", "krb_realm", "map"]}, "comparison_hash": "c58b84e18bba9d75d595bab34b326eb6a8580a80636f79642c4af8843e7123cf"}, "13": {"facts": [{"label": "Method", "value": "gss"}, {"label": "Configuration", "value": "pg_hba.conf"}, {"label": "Inventory", "value": "User-visible source authentication method"}], "tables": [{"key": "method-options", "rows": [{"name": "include_realm", "description": "If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping ( Section 20.2 ). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless krb_realm is also used. It is recommended to leave include_realm set to the default (1) and to provide an explicit mapping in pg_ident.conf to convert principal names to PostgreSQL user names."}, {"name": "map", "description": "Allows mapping from client principals to database user names. See Section 20.2 for details. For a GSSAPI/Kerberos principal, such as username@EXAMPLE.COM (or, less commonly, username/hostbased@EXAMPLE.COM ), the user name used for mapping is username@EXAMPLE.COM (or username/hostbased@EXAMPLE.COM , respectively), unless include_realm has been set to 0, in which case username (or username/hostbased ) is what is seen as the system user name when mapping."}, {"name": "krb_realm", "description": "Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done."}], "title": "Documented method options and alternatives", "columns": [{"key": "name", "label": "Option or term"}, {"key": "description", "label": "Meaning"}]}], "aliases": [], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v13.23/postgresql-13.23.tar.bz2", "label": "13.23", "major": "13", "channel": "historical", "revision": "6ec3c82726af92b7dec873fa1cdf881eca92a4219787dfad05acb6b10e041fd6", "source_sha256": "6ec3c82726af92b7dec873fa1cdf881eca92a4219787dfad05acb6b10e041fd6", "catalog_fingerprint": "c7015c845255c9d721c547c8ab9ef37825d332588c9691d982e6906b7d571002"}, "sources": [{"url": "https://ftp.postgresql.org/pub/source/v13.23/postgresql-13.23.tar.bz2", "label": "Matching PostgreSQL source archive", "sha256": "6ec3c82726af92b7dec873fa1cdf881eca92a4219787dfad05acb6b10e041fd6"}, {"url": "/docs/13/gssapi-auth.html", "path": "gssapi-auth.html", "label": "PostgreSQL 13 English manual", "sha256": "4e0099fbc60cc16079a25f6188de6e2123bb58bc2b4e1a0aceb7cedda0872776"}, {"url": "/docs/13/auth-pg-hba-conf.html", "path": "auth-pg-hba-conf.html", "label": "PostgreSQL 13 English manual", "sha256": "3cc6ce851945cba450e6b26ecf9cae1efd3c03fb7b55e17876f4d9ea418a7c2e"}], "sections": [], "signature": "", "attributes": {"method": "gss", "inventory": "User-visible source authentication method", "configuration": "pg_hba.conf"}, "description": ["Use GSSAPI to authenticate the user. This is only available for TCP/IP connections. See Section 20.6 for details. It can be used in conjunction with GSSAPI encryption."], "manual_html": "<div class=\"sect1\" id=\"GSSAPI-AUTH\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h2 class=\"title\">20.6.\u00a0GSSAPI Authentication</h2>\n</div>\n</div>\n</div>\n<p><span class=\"productname\">GSSAPI</span> is an industry-standard protocol for secure authentication defined in <a class=\"ulink\" href=\"https://datatracker.ietf.org/doc/html/rfc2743\">RFC 2743</a>. <span class=\"productname\">PostgreSQL</span> supports <span class=\"productname\">GSSAPI</span> for authentication, communications encryption, or both. <span class=\"productname\">GSSAPI</span> provides automatic authentication (single sign-on) for systems that support it. The authentication itself is secure. If <span class=\"productname\">GSSAPI</span> encryption or SSL encryption is used, the data sent along the database connection will be encrypted; otherwise, it will not.</p>\n<p>GSSAPI support has to be enabled when <span class=\"productname\">PostgreSQL</span> is built; see <a class=\"xref\" href=\"/docs/13/installation.html\" title=\"Chapter\u00a016.\u00a0Installation from Source Code\">Chapter\u00a016</a> for more information.</p>\n<p>When <span class=\"productname\">GSSAPI</span> uses <span class=\"productname\">Kerberos</span>, it uses a standard service principal (authentication identity) name in the format <code class=\"literal\"><em class=\"replaceable\"><code>servicename</code></em>/<em class=\"replaceable\"><code>hostname</code></em>@<em class=\"replaceable\"><code>realm</code></em></code>. The principal name used by a particular installation is not encoded in the <span class=\"productname\">PostgreSQL</span> server in any way; rather it is specified in the <em class=\"firstterm\">keytab</em> file that the server reads to determine its identity. If multiple principals are listed in the keytab file, the server will accept any one of them. The server's realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the server.</p>\n<p>When connecting, the client must know the principal name of the server it intends to connect to. The <em class=\"replaceable\"><code>servicename</code></em> part of the principal is ordinarily <code class=\"literal\">postgres</code>, but another value can be selected via <span class=\"application\">libpq</span>'s <a class=\"xref\" href=\"/docs/13/libpq-connect.html#LIBPQ-CONNECT-KRBSRVNAME\">krbsrvname</a> connection parameter. The <em class=\"replaceable\"><code>hostname</code></em> part is the fully qualified host name that <span class=\"application\">libpq</span> is told to connect to. The realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the client.</p>\n<p>The client will also have a principal name for its own identity (and it must have a valid ticket for this principal). To use <span class=\"productname\">GSSAPI</span> for authentication, the client principal must be associated with a <span class=\"productname\">PostgreSQL</span> database user name. The <code class=\"filename\">pg_ident.conf</code> configuration file can be used to map principals to user names; for example, <code class=\"literal\">pgusername@realm</code> could be mapped to just <code class=\"literal\">pgusername</code>. Alternatively, you can use the full <code class=\"literal\">username@realm</code> principal as the role name in <span class=\"productname\">PostgreSQL</span> without any mapping.</p>\n<p><span class=\"productname\">PostgreSQL</span> also supports mapping client principals to user names by just stripping the realm from the principal. This method is supported for backwards compatibility and is strongly discouraged as it is then impossible to distinguish different users with the same user name but coming from different realms. To enable this, set <code class=\"literal\">include_realm</code> to 0. For simple single-realm installations, doing that combined with setting the <code class=\"literal\">krb_realm</code> parameter (which checks that the principal's realm matches exactly what is in the <code class=\"literal\">krb_realm</code> parameter) is still secure; but this is a less capable approach compared to specifying an explicit mapping in <code class=\"filename\">pg_ident.conf</code>.</p>\n<p>The location of the server's keytab file is specified by the <a class=\"xref\" href=\"/docs/13/runtime-config-connection.html#GUC-KRB-SERVER-KEYFILE\">krb_server_keyfile</a> configuration parameter. For security reasons, it is recommended to use a separate keytab just for the <span class=\"productname\">PostgreSQL</span> server rather than allowing the server to read the system keytab file. Make sure that your server keytab file is readable (and preferably only readable, not writable) by the <span class=\"productname\">PostgreSQL</span> server account. (See also <a class=\"xref\" href=\"/docs/13/postgres-user.html\" title=\"18.1.\u00a0The PostgreSQL User Account\">Section\u00a018.1</a>.)</p>\n<p>The keytab file is generated using the Kerberos software; see the Kerberos documentation for details. The following example shows doing this using the <span class=\"application\">kadmin</span> tool of MIT-compatible Kerberos 5 implementations:</p>\n<pre class=\"screen\"><code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>addprinc -randkey postgres/server.my.domain.org</code></strong>\n<code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>ktadd -k krb5.keytab postgres/server.my.domain.org</code></strong>\n</pre>\n<p>The following authentication options are supported for the <span class=\"productname\">GSSAPI</span> authentication method:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">include_realm</code></span></dt>\n<dd>\n<p>If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping (<a class=\"xref\" href=\"/docs/13/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a>). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless <code class=\"literal\">krb_realm</code> is also used. It is recommended to leave <code class=\"literal\">include_realm</code> set to the default (1) and to provide an explicit mapping in <code class=\"filename\">pg_ident.conf</code> to convert principal names to <span class=\"productname\">PostgreSQL</span> user names.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">map</code></span></dt>\n<dd>\n<p>Allows mapping from client principals to database user names. See <a class=\"xref\" href=\"/docs/13/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a> for details. For a GSSAPI/Kerberos principal, such as <code class=\"literal\">username@EXAMPLE.COM</code> (or, less commonly, <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>), the user name used for mapping is <code class=\"literal\">username@EXAMPLE.COM</code> (or <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>, respectively), unless <code class=\"literal\">include_realm</code> has been set to 0, in which case <code class=\"literal\">username</code> (or <code class=\"literal\">username/hostbased</code>) is what is seen as the system user name when mapping.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">krb_realm</code></span></dt>\n<dd>\n<p>Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done.</p>\n</dd>\n</dl>\n</div>\n<p>In addition to these settings, which can be different for different <code class=\"filename\">pg_hba.conf</code> entries, there is the server-wide <a class=\"xref\" href=\"/docs/13/runtime-config-connection.html#GUC-KRB-CASEINS-USERS\">krb_caseins_users</a> configuration parameter. If that is set to true, client principals are matched to user map entries case-insensitively. <code class=\"literal\">krb_realm</code>, if set, is also matched case-insensitively.</p>\n</div>", "manual_path": "/docs/13/gssapi-auth.html", "comparison_data": {"method": "gss", "documented_option_names": ["include_realm", "krb_realm", "map"]}, "comparison_hash": "c58b84e18bba9d75d595bab34b326eb6a8580a80636f79642c4af8843e7123cf"}, "14": {"facts": [{"label": "Method", "value": "gss"}, {"label": "Configuration", "value": "pg_hba.conf"}, {"label": "Inventory", "value": "User-visible source authentication method"}], "tables": [{"key": "method-options", "rows": [{"name": "include_realm", "description": "If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping ( Section 21.2 ). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless krb_realm is also used. It is recommended to leave include_realm set to the default (1) and to provide an explicit mapping in pg_ident.conf to convert principal names to PostgreSQL user names."}, {"name": "map", "description": "Allows mapping from client principals to database user names. See Section 21.2 for details. For a GSSAPI/Kerberos principal, such as username@EXAMPLE.COM (or, less commonly, username/hostbased@EXAMPLE.COM ), the user name used for mapping is username@EXAMPLE.COM (or username/hostbased@EXAMPLE.COM , respectively), unless include_realm has been set to 0, in which case username (or username/hostbased ) is what is seen as the system user name when mapping."}, {"name": "krb_realm", "description": "Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done."}], "title": "Documented method options and alternatives", "columns": [{"key": "name", "label": "Option or term"}, {"key": "description", "label": "Meaning"}]}], "aliases": [], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v14.24/postgresql-14.24.tar.bz2", "label": "14.24", "major": "14", "channel": "stable", "revision": "a7fa7ed3d558172355f51406097a7bd4f6b473be80f311ef7cda96bf383d8897", "source_sha256": "a7fa7ed3d558172355f51406097a7bd4f6b473be80f311ef7cda96bf383d8897", "catalog_fingerprint": "b272e6a82e4c46efda81c3a6a4cdf7de6a83dfff7f02f226a392fbe9acdd3adb"}, "sources": [{"url": "https://ftp.postgresql.org/pub/source/v14.24/postgresql-14.24.tar.bz2", "label": "Matching PostgreSQL source archive", "sha256": "a7fa7ed3d558172355f51406097a7bd4f6b473be80f311ef7cda96bf383d8897"}, {"url": "/docs/14/gssapi-auth.html", "path": "gssapi-auth.html", "label": "PostgreSQL 14 English manual", "sha256": "011fe931c24ac53aeb85f98a816976e6c12c754b115fc458c37af750f5404c7e"}, {"url": "/docs/14/auth-pg-hba-conf.html", "path": "auth-pg-hba-conf.html", "label": "PostgreSQL 14 English manual", "sha256": "c9a75f04fd4a1069ea261ba061578a75c47a4b7e0bbf88761502fd4c19ccbc3f"}], "sections": [], "signature": "", "attributes": {"method": "gss", "inventory": "User-visible source authentication method", "configuration": "pg_hba.conf"}, "description": ["Use GSSAPI to authenticate the user. This is only available for TCP/IP connections. See Section 21.6 for details. It can be used in conjunction with GSSAPI encryption."], "manual_html": "<div class=\"sect1\" id=\"GSSAPI-AUTH\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h2 class=\"title\">21.6.\u00a0GSSAPI Authentication</h2>\n</div>\n</div>\n</div>\n<p><span class=\"productname\">GSSAPI</span> is an industry-standard protocol for secure authentication defined in <a class=\"ulink\" href=\"https://datatracker.ietf.org/doc/html/rfc2743\">RFC 2743</a>. <span class=\"productname\">PostgreSQL</span> supports <span class=\"productname\">GSSAPI</span> for authentication, communications encryption, or both. <span class=\"productname\">GSSAPI</span> provides automatic authentication (single sign-on) for systems that support it. The authentication itself is secure. If <span class=\"productname\">GSSAPI</span> encryption or SSL encryption is used, the data sent along the database connection will be encrypted; otherwise, it will not.</p>\n<p>GSSAPI support has to be enabled when <span class=\"productname\">PostgreSQL</span> is built; see <a class=\"xref\" href=\"/docs/14/installation.html\" title=\"Chapter\u00a017.\u00a0Installation from Source Code\">Chapter\u00a017</a> for more information.</p>\n<p>When <span class=\"productname\">GSSAPI</span> uses <span class=\"productname\">Kerberos</span>, it uses a standard service principal (authentication identity) name in the format <code class=\"literal\"><em class=\"replaceable\"><code>servicename</code></em>/<em class=\"replaceable\"><code>hostname</code></em>@<em class=\"replaceable\"><code>realm</code></em></code>. The principal name used by a particular installation is not encoded in the <span class=\"productname\">PostgreSQL</span> server in any way; rather it is specified in the <em class=\"firstterm\">keytab</em> file that the server reads to determine its identity. If multiple principals are listed in the keytab file, the server will accept any one of them. The server's realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the server.</p>\n<p>When connecting, the client must know the principal name of the server it intends to connect to. The <em class=\"replaceable\"><code>servicename</code></em> part of the principal is ordinarily <code class=\"literal\">postgres</code>, but another value can be selected via <span class=\"application\">libpq</span>'s <a class=\"xref\" href=\"/docs/14/libpq-connect.html#LIBPQ-CONNECT-KRBSRVNAME\">krbsrvname</a> connection parameter. The <em class=\"replaceable\"><code>hostname</code></em> part is the fully qualified host name that <span class=\"application\">libpq</span> is told to connect to. The realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the client.</p>\n<p>The client will also have a principal name for its own identity (and it must have a valid ticket for this principal). To use <span class=\"productname\">GSSAPI</span> for authentication, the client principal must be associated with a <span class=\"productname\">PostgreSQL</span> database user name. The <code class=\"filename\">pg_ident.conf</code> configuration file can be used to map principals to user names; for example, <code class=\"literal\">pgusername@realm</code> could be mapped to just <code class=\"literal\">pgusername</code>. Alternatively, you can use the full <code class=\"literal\">username@realm</code> principal as the role name in <span class=\"productname\">PostgreSQL</span> without any mapping.</p>\n<p><span class=\"productname\">PostgreSQL</span> also supports mapping client principals to user names by just stripping the realm from the principal. This method is supported for backwards compatibility and is strongly discouraged as it is then impossible to distinguish different users with the same user name but coming from different realms. To enable this, set <code class=\"literal\">include_realm</code> to 0. For simple single-realm installations, doing that combined with setting the <code class=\"literal\">krb_realm</code> parameter (which checks that the principal's realm matches exactly what is in the <code class=\"literal\">krb_realm</code> parameter) is still secure; but this is a less capable approach compared to specifying an explicit mapping in <code class=\"filename\">pg_ident.conf</code>.</p>\n<p>The location of the server's keytab file is specified by the <a class=\"xref\" href=\"/docs/14/runtime-config-connection.html#GUC-KRB-SERVER-KEYFILE\">krb_server_keyfile</a> configuration parameter. For security reasons, it is recommended to use a separate keytab just for the <span class=\"productname\">PostgreSQL</span> server rather than allowing the server to read the system keytab file. Make sure that your server keytab file is readable (and preferably only readable, not writable) by the <span class=\"productname\">PostgreSQL</span> server account. (See also <a class=\"xref\" href=\"/docs/14/postgres-user.html\" title=\"19.1.\u00a0The PostgreSQL User Account\">Section\u00a019.1</a>.)</p>\n<p>The keytab file is generated using the Kerberos software; see the Kerberos documentation for details. The following example shows doing this using the <span class=\"application\">kadmin</span> tool of MIT-compatible Kerberos 5 implementations:</p>\n<pre class=\"screen\"><code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>addprinc -randkey postgres/server.my.domain.org</code></strong>\n<code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>ktadd -k krb5.keytab postgres/server.my.domain.org</code></strong>\n</pre>\n<p>The following authentication options are supported for the <span class=\"productname\">GSSAPI</span> authentication method:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">include_realm</code></span></dt>\n<dd>\n<p>If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping (<a class=\"xref\" href=\"/docs/14/auth-username-maps.html\" title=\"21.2.\u00a0User Name Maps\">Section\u00a021.2</a>). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless <code class=\"literal\">krb_realm</code> is also used. It is recommended to leave <code class=\"literal\">include_realm</code> set to the default (1) and to provide an explicit mapping in <code class=\"filename\">pg_ident.conf</code> to convert principal names to <span class=\"productname\">PostgreSQL</span> user names.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">map</code></span></dt>\n<dd>\n<p>Allows mapping from client principals to database user names. See <a class=\"xref\" href=\"/docs/14/auth-username-maps.html\" title=\"21.2.\u00a0User Name Maps\">Section\u00a021.2</a> for details. For a GSSAPI/Kerberos principal, such as <code class=\"literal\">username@EXAMPLE.COM</code> (or, less commonly, <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>), the user name used for mapping is <code class=\"literal\">username@EXAMPLE.COM</code> (or <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>, respectively), unless <code class=\"literal\">include_realm</code> has been set to 0, in which case <code class=\"literal\">username</code> (or <code class=\"literal\">username/hostbased</code>) is what is seen as the system user name when mapping.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">krb_realm</code></span></dt>\n<dd>\n<p>Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done.</p>\n</dd>\n</dl>\n</div>\n<p>In addition to these settings, which can be different for different <code class=\"filename\">pg_hba.conf</code> entries, there is the server-wide <a class=\"xref\" href=\"/docs/14/runtime-config-connection.html#GUC-KRB-CASEINS-USERS\">krb_caseins_users</a> configuration parameter. If that is set to true, client principals are matched to user map entries case-insensitively. <code class=\"literal\">krb_realm</code>, if set, is also matched case-insensitively.</p>\n</div>", "manual_path": "/docs/14/gssapi-auth.html", "comparison_data": {"method": "gss", "documented_option_names": ["include_realm", "krb_realm", "map"]}, "comparison_hash": "c58b84e18bba9d75d595bab34b326eb6a8580a80636f79642c4af8843e7123cf"}, "15": {"facts": [{"label": "Method", "value": "gss"}, {"label": "Configuration", "value": "pg_hba.conf"}, {"label": "Inventory", "value": "User-visible source authentication method"}], "tables": [{"key": "method-options", "rows": [{"name": "include_realm", "description": "If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping ( Section 21.2 ). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless krb_realm is also used. It is recommended to leave include_realm set to the default (1) and to provide an explicit mapping in pg_ident.conf to convert principal names to PostgreSQL user names."}, {"name": "map", "description": "Allows mapping from client principals to database user names. See Section 21.2 for details. For a GSSAPI/Kerberos principal, such as username@EXAMPLE.COM (or, less commonly, username/hostbased@EXAMPLE.COM ), the user name used for mapping is username@EXAMPLE.COM (or username/hostbased@EXAMPLE.COM , respectively), unless include_realm has been set to 0, in which case username (or username/hostbased ) is what is seen as the system user name when mapping."}, {"name": "krb_realm", "description": "Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done."}], "title": "Documented method options and alternatives", "columns": [{"key": "name", "label": "Option or term"}, {"key": "description", "label": "Meaning"}]}], "aliases": [], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v15.19/postgresql-15.19.tar.bz2", "label": "15.19", "major": "15", "channel": "stable", "revision": "e1a64a87a46b825b88c082e4518161a47aab53c45694964f8ba1df28f7859f89", "source_sha256": "e1a64a87a46b825b88c082e4518161a47aab53c45694964f8ba1df28f7859f89", "catalog_fingerprint": "fefe3c425147a86defada190c9b0663cfe02caa1724f5dede93e46457572252d"}, "sources": [{"url": "https://ftp.postgresql.org/pub/source/v15.19/postgresql-15.19.tar.bz2", "label": "Matching PostgreSQL source archive", "sha256": "e1a64a87a46b825b88c082e4518161a47aab53c45694964f8ba1df28f7859f89"}, {"url": "/docs/15/gssapi-auth.html", "path": "gssapi-auth.html", "label": "PostgreSQL 15 English manual", "sha256": "16f71c4b4c07cc5f56deeb8f302e0bacfeeea542558aa5b77da7be2eb81fdeb9"}, {"url": "/docs/15/auth-pg-hba-conf.html", "path": "auth-pg-hba-conf.html", "label": "PostgreSQL 15 English manual", "sha256": "0470cd3eeb82cbc32d4b8b79e29f4427bdfd01f5bb15e6d9b7cee2f6dd2bba44"}], "sections": [], "signature": "", "attributes": {"method": "gss", "inventory": "User-visible source authentication method", "configuration": "pg_hba.conf"}, "description": ["Use GSSAPI to authenticate the user. This is only available for TCP/IP connections. See Section 21.6 for details. It can be used in conjunction with GSSAPI encryption."], "manual_html": "<div class=\"sect1\" id=\"GSSAPI-AUTH\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h2 class=\"title\">21.6.\u00a0GSSAPI Authentication</h2>\n</div>\n</div>\n</div>\n<p><span class=\"productname\">GSSAPI</span> is an industry-standard protocol for secure authentication defined in <a class=\"ulink\" href=\"https://datatracker.ietf.org/doc/html/rfc2743\">RFC 2743</a>. <span class=\"productname\">PostgreSQL</span> supports <span class=\"productname\">GSSAPI</span> for authentication, communications encryption, or both. <span class=\"productname\">GSSAPI</span> provides automatic authentication (single sign-on) for systems that support it. The authentication itself is secure. If <span class=\"productname\">GSSAPI</span> encryption or SSL encryption is used, the data sent along the database connection will be encrypted; otherwise, it will not.</p>\n<p>GSSAPI support has to be enabled when <span class=\"productname\">PostgreSQL</span> is built; see <a class=\"xref\" href=\"/docs/15/installation.html\" title=\"Chapter\u00a017.\u00a0Installation from Source Code\">Chapter\u00a017</a> for more information.</p>\n<p>When <span class=\"productname\">GSSAPI</span> uses <span class=\"productname\">Kerberos</span>, it uses a standard service principal (authentication identity) name in the format <code class=\"literal\"><em class=\"replaceable\"><code>servicename</code></em>/<em class=\"replaceable\"><code>hostname</code></em>@<em class=\"replaceable\"><code>realm</code></em></code>. The principal name used by a particular installation is not encoded in the <span class=\"productname\">PostgreSQL</span> server in any way; rather it is specified in the <em class=\"firstterm\">keytab</em> file that the server reads to determine its identity. If multiple principals are listed in the keytab file, the server will accept any one of them. The server's realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the server.</p>\n<p>When connecting, the client must know the principal name of the server it intends to connect to. The <em class=\"replaceable\"><code>servicename</code></em> part of the principal is ordinarily <code class=\"literal\">postgres</code>, but another value can be selected via <span class=\"application\">libpq</span>'s <a class=\"xref\" href=\"/docs/15/libpq-connect.html#LIBPQ-CONNECT-KRBSRVNAME\">krbsrvname</a> connection parameter. The <em class=\"replaceable\"><code>hostname</code></em> part is the fully qualified host name that <span class=\"application\">libpq</span> is told to connect to. The realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the client.</p>\n<p>The client will also have a principal name for its own identity (and it must have a valid ticket for this principal). To use <span class=\"productname\">GSSAPI</span> for authentication, the client principal must be associated with a <span class=\"productname\">PostgreSQL</span> database user name. The <code class=\"filename\">pg_ident.conf</code> configuration file can be used to map principals to user names; for example, <code class=\"literal\">pgusername@realm</code> could be mapped to just <code class=\"literal\">pgusername</code>. Alternatively, you can use the full <code class=\"literal\">username@realm</code> principal as the role name in <span class=\"productname\">PostgreSQL</span> without any mapping.</p>\n<p><span class=\"productname\">PostgreSQL</span> also supports mapping client principals to user names by just stripping the realm from the principal. This method is supported for backwards compatibility and is strongly discouraged as it is then impossible to distinguish different users with the same user name but coming from different realms. To enable this, set <code class=\"literal\">include_realm</code> to 0. For simple single-realm installations, doing that combined with setting the <code class=\"literal\">krb_realm</code> parameter (which checks that the principal's realm matches exactly what is in the <code class=\"literal\">krb_realm</code> parameter) is still secure; but this is a less capable approach compared to specifying an explicit mapping in <code class=\"filename\">pg_ident.conf</code>.</p>\n<p>The location of the server's keytab file is specified by the <a class=\"xref\" href=\"/docs/15/runtime-config-connection.html#GUC-KRB-SERVER-KEYFILE\">krb_server_keyfile</a> configuration parameter. For security reasons, it is recommended to use a separate keytab just for the <span class=\"productname\">PostgreSQL</span> server rather than allowing the server to read the system keytab file. Make sure that your server keytab file is readable (and preferably only readable, not writable) by the <span class=\"productname\">PostgreSQL</span> server account. (See also <a class=\"xref\" href=\"/docs/15/postgres-user.html\" title=\"19.1.\u00a0The PostgreSQL User Account\">Section\u00a019.1</a>.)</p>\n<p>The keytab file is generated using the Kerberos software; see the Kerberos documentation for details. The following example shows doing this using the <span class=\"application\">kadmin</span> tool of MIT-compatible Kerberos 5 implementations:</p>\n<pre class=\"screen\"><code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>addprinc -randkey postgres/server.my.domain.org</code></strong>\n<code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>ktadd -k krb5.keytab postgres/server.my.domain.org</code></strong>\n</pre>\n<p>The following authentication options are supported for the <span class=\"productname\">GSSAPI</span> authentication method:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">include_realm</code></span></dt>\n<dd>\n<p>If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping (<a class=\"xref\" href=\"/docs/15/auth-username-maps.html\" title=\"21.2.\u00a0User Name Maps\">Section\u00a021.2</a>). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless <code class=\"literal\">krb_realm</code> is also used. It is recommended to leave <code class=\"literal\">include_realm</code> set to the default (1) and to provide an explicit mapping in <code class=\"filename\">pg_ident.conf</code> to convert principal names to <span class=\"productname\">PostgreSQL</span> user names.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">map</code></span></dt>\n<dd>\n<p>Allows mapping from client principals to database user names. See <a class=\"xref\" href=\"/docs/15/auth-username-maps.html\" title=\"21.2.\u00a0User Name Maps\">Section\u00a021.2</a> for details. For a GSSAPI/Kerberos principal, such as <code class=\"literal\">username@EXAMPLE.COM</code> (or, less commonly, <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>), the user name used for mapping is <code class=\"literal\">username@EXAMPLE.COM</code> (or <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>, respectively), unless <code class=\"literal\">include_realm</code> has been set to 0, in which case <code class=\"literal\">username</code> (or <code class=\"literal\">username/hostbased</code>) is what is seen as the system user name when mapping.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">krb_realm</code></span></dt>\n<dd>\n<p>Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done.</p>\n</dd>\n</dl>\n</div>\n<p>In addition to these settings, which can be different for different <code class=\"filename\">pg_hba.conf</code> entries, there is the server-wide <a class=\"xref\" href=\"/docs/15/runtime-config-connection.html#GUC-KRB-CASEINS-USERS\">krb_caseins_users</a> configuration parameter. If that is set to true, client principals are matched to user map entries case-insensitively. <code class=\"literal\">krb_realm</code>, if set, is also matched case-insensitively.</p>\n</div>", "manual_path": "/docs/15/gssapi-auth.html", "comparison_data": {"method": "gss", "documented_option_names": ["include_realm", "krb_realm", "map"]}, "comparison_hash": "c58b84e18bba9d75d595bab34b326eb6a8580a80636f79642c4af8843e7123cf"}, "16": {"facts": [{"label": "Method", "value": "gss"}, {"label": "Configuration", "value": "pg_hba.conf"}, {"label": "Inventory", "value": "User-visible source authentication method"}], "tables": [{"key": "method-options", "rows": [{"name": "include_realm", "description": "If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping ( Section 21.2 ). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless krb_realm is also used. It is recommended to leave include_realm set to the default (1) and to provide an explicit mapping in pg_ident.conf to convert principal names to PostgreSQL user names."}, {"name": "map", "description": "Allows mapping from client principals to database user names. See Section 21.2 for details. For a GSSAPI/Kerberos principal, such as username@EXAMPLE.COM (or, less commonly, username/hostbased@EXAMPLE.COM ), the user name used for mapping is username@EXAMPLE.COM (or username/hostbased@EXAMPLE.COM , respectively), unless include_realm has been set to 0, in which case username (or username/hostbased ) is what is seen as the system user name when mapping."}, {"name": "krb_realm", "description": "Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done."}], "title": "Documented method options and alternatives", "columns": [{"key": "name", "label": "Option or term"}, {"key": "description", "label": "Meaning"}]}], "aliases": [], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v16.15/postgresql-16.15.tar.bz2", "label": "16.15", "major": "16", "channel": "stable", "revision": "c1575341fa7bd40f5274ea465b34390f4dc64cdd0770af327005caaeb9f6b7ed", "source_sha256": "c1575341fa7bd40f5274ea465b34390f4dc64cdd0770af327005caaeb9f6b7ed", "catalog_fingerprint": "fa133458dc8f52e15083b4f59b7a582e2e378b608d3ac5c53054df458a374e23"}, "sources": [{"url": "https://ftp.postgresql.org/pub/source/v16.15/postgresql-16.15.tar.bz2", "label": "Matching PostgreSQL source archive", "sha256": "c1575341fa7bd40f5274ea465b34390f4dc64cdd0770af327005caaeb9f6b7ed"}, {"url": "/docs/16/gssapi-auth.html", "path": "gssapi-auth.html", "label": "PostgreSQL 16 English manual", "sha256": "7e04796130a51899cc5c7fa3cc162f962c8db7608b0c67011e42b0ac011aac96"}, {"url": "/docs/16/auth-pg-hba-conf.html", "path": "auth-pg-hba-conf.html", "label": "PostgreSQL 16 English manual", "sha256": "ccc5146375a184646d5992edbc693e12c0de4431a35141d6b56c8dd6b3c52132"}], "sections": [], "signature": "", "attributes": {"method": "gss", "inventory": "User-visible source authentication method", "configuration": "pg_hba.conf"}, "description": ["Use GSSAPI to authenticate the user. This is only available for TCP/IP connections. See Section 21.6 for details. It can be used in conjunction with GSSAPI encryption."], "manual_html": "<div class=\"sect1\" id=\"GSSAPI-AUTH\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h2 class=\"title\">21.6.\u00a0GSSAPI Authentication </h2>\n</div>\n</div>\n</div>\n<p><span class=\"productname\">GSSAPI</span> is an industry-standard protocol for secure authentication defined in <a class=\"ulink\" href=\"https://datatracker.ietf.org/doc/html/rfc2743\">RFC 2743</a>. <span class=\"productname\">PostgreSQL</span> supports <span class=\"productname\">GSSAPI</span> for authentication, communications encryption, or both. <span class=\"productname\">GSSAPI</span> provides automatic authentication (single sign-on) for systems that support it. The authentication itself is secure. If <span class=\"productname\">GSSAPI</span> encryption or SSL encryption is used, the data sent along the database connection will be encrypted; otherwise, it will not.</p>\n<p>GSSAPI support has to be enabled when <span class=\"productname\">PostgreSQL</span> is built; see <a class=\"xref\" href=\"/docs/16/installation.html\" title=\"Chapter\u00a017.\u00a0Installation from Source Code\">Chapter\u00a017</a> for more information.</p>\n<p>When <span class=\"productname\">GSSAPI</span> uses <span class=\"productname\">Kerberos</span>, it uses a standard service principal (authentication identity) name in the format <code class=\"literal\"><em class=\"replaceable\"><code>servicename</code></em>/<em class=\"replaceable\"><code>hostname</code></em>@<em class=\"replaceable\"><code>realm</code></em></code>. The principal name used by a particular installation is not encoded in the <span class=\"productname\">PostgreSQL</span> server in any way; rather it is specified in the <em class=\"firstterm\">keytab</em> file that the server reads to determine its identity. If multiple principals are listed in the keytab file, the server will accept any one of them. The server's realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the server.</p>\n<p>When connecting, the client must know the principal name of the server it intends to connect to. The <em class=\"replaceable\"><code>servicename</code></em> part of the principal is ordinarily <code class=\"literal\">postgres</code>, but another value can be selected via <span class=\"application\">libpq</span>'s <a class=\"xref\" href=\"/docs/16/libpq-connect.html#LIBPQ-CONNECT-KRBSRVNAME\">krbsrvname</a> connection parameter. The <em class=\"replaceable\"><code>hostname</code></em> part is the fully qualified host name that <span class=\"application\">libpq</span> is told to connect to. The realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the client.</p>\n<p>The client will also have a principal name for its own identity (and it must have a valid ticket for this principal). To use <span class=\"productname\">GSSAPI</span> for authentication, the client principal must be associated with a <span class=\"productname\">PostgreSQL</span> database user name. The <code class=\"filename\">pg_ident.conf</code> configuration file can be used to map principals to user names; for example, <code class=\"literal\">pgusername@realm</code> could be mapped to just <code class=\"literal\">pgusername</code>. Alternatively, you can use the full <code class=\"literal\">username@realm</code> principal as the role name in <span class=\"productname\">PostgreSQL</span> without any mapping.</p>\n<p><span class=\"productname\">PostgreSQL</span> also supports mapping client principals to user names by just stripping the realm from the principal. This method is supported for backwards compatibility and is strongly discouraged as it is then impossible to distinguish different users with the same user name but coming from different realms. To enable this, set <code class=\"literal\">include_realm</code> to 0. For simple single-realm installations, doing that combined with setting the <code class=\"literal\">krb_realm</code> parameter (which checks that the principal's realm matches exactly what is in the <code class=\"literal\">krb_realm</code> parameter) is still secure; but this is a less capable approach compared to specifying an explicit mapping in <code class=\"filename\">pg_ident.conf</code>.</p>\n<p>The location of the server's keytab file is specified by the <a class=\"xref\" href=\"/docs/16/runtime-config-connection.html#GUC-KRB-SERVER-KEYFILE\">krb_server_keyfile</a> configuration parameter. For security reasons, it is recommended to use a separate keytab just for the <span class=\"productname\">PostgreSQL</span> server rather than allowing the server to read the system keytab file. Make sure that your server keytab file is readable (and preferably only readable, not writable) by the <span class=\"productname\">PostgreSQL</span> server account. (See also <a class=\"xref\" href=\"/docs/16/postgres-user.html\" title=\"19.1.\u00a0The PostgreSQL User Account\">Section\u00a019.1</a>.)</p>\n<p>The keytab file is generated using the Kerberos software; see the Kerberos documentation for details. The following example shows doing this using the <span class=\"application\">kadmin</span> tool of MIT Kerberos:</p>\n<pre class=\"screen\"><code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>addprinc -randkey postgres/server.my.domain.org</code></strong>\n<code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>ktadd -k krb5.keytab postgres/server.my.domain.org</code></strong>\n</pre>\n<p>The following authentication options are supported for the <span class=\"productname\">GSSAPI</span> authentication method:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">include_realm</code></span></dt>\n<dd>\n<p>If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping (<a class=\"xref\" href=\"/docs/16/auth-username-maps.html\" title=\"21.2.\u00a0User Name Maps\">Section\u00a021.2</a>). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless <code class=\"literal\">krb_realm</code> is also used. It is recommended to leave <code class=\"literal\">include_realm</code> set to the default (1) and to provide an explicit mapping in <code class=\"filename\">pg_ident.conf</code> to convert principal names to <span class=\"productname\">PostgreSQL</span> user names.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">map</code></span></dt>\n<dd>\n<p>Allows mapping from client principals to database user names. See <a class=\"xref\" href=\"/docs/16/auth-username-maps.html\" title=\"21.2.\u00a0User Name Maps\">Section\u00a021.2</a> for details. For a GSSAPI/Kerberos principal, such as <code class=\"literal\">username@EXAMPLE.COM</code> (or, less commonly, <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>), the user name used for mapping is <code class=\"literal\">username@EXAMPLE.COM</code> (or <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>, respectively), unless <code class=\"literal\">include_realm</code> has been set to 0, in which case <code class=\"literal\">username</code> (or <code class=\"literal\">username/hostbased</code>) is what is seen as the system user name when mapping.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">krb_realm</code></span></dt>\n<dd>\n<p>Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done.</p>\n</dd>\n</dl>\n</div>\n<p>In addition to these settings, which can be different for different <code class=\"filename\">pg_hba.conf</code> entries, there is the server-wide <a class=\"xref\" href=\"/docs/16/runtime-config-connection.html#GUC-KRB-CASEINS-USERS\">krb_caseins_users</a> configuration parameter. If that is set to true, client principals are matched to user map entries case-insensitively. <code class=\"literal\">krb_realm</code>, if set, is also matched case-insensitively.</p>\n</div>", "manual_path": "/docs/16/gssapi-auth.html", "comparison_data": {"method": "gss", "documented_option_names": ["include_realm", "krb_realm", "map"]}, "comparison_hash": "c58b84e18bba9d75d595bab34b326eb6a8580a80636f79642c4af8843e7123cf"}, "17": {"facts": [{"label": "Method", "value": "gss"}, {"label": "Configuration", "value": "pg_hba.conf"}, {"label": "Inventory", "value": "User-visible source authentication method"}], "tables": [{"key": "method-options", "rows": [{"name": "include_realm", "description": "If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping ( Section 20.2 ). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless krb_realm is also used. It is recommended to leave include_realm set to the default (1) and to provide an explicit mapping in pg_ident.conf to convert principal names to PostgreSQL user names."}, {"name": "map", "description": "Allows mapping from client principals to database user names. See Section 20.2 for details. For a GSSAPI/Kerberos principal, such as username@EXAMPLE.COM (or, less commonly, username/hostbased@EXAMPLE.COM ), the user name used for mapping is username@EXAMPLE.COM (or username/hostbased@EXAMPLE.COM , respectively), unless include_realm has been set to 0, in which case username (or username/hostbased ) is what is seen as the system user name when mapping."}, {"name": "krb_realm", "description": "Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done."}], "title": "Documented method options and alternatives", "columns": [{"key": "name", "label": "Option or term"}, {"key": "description", "label": "Meaning"}]}], "aliases": [], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v17.11/postgresql-17.11.tar.bz2", "label": "17.11", "major": "17", "channel": "stable", "revision": "dd27f2b3c59e73ed14aa3324901242bf69a032a6347805f274e6260322d42979", "source_sha256": "dd27f2b3c59e73ed14aa3324901242bf69a032a6347805f274e6260322d42979", "catalog_fingerprint": "4bbe3ac77becd618478f66aec420a533e9017be356c5c1d51a4b17f0fd497c07"}, "sources": [{"url": "https://ftp.postgresql.org/pub/source/v17.11/postgresql-17.11.tar.bz2", "label": "Matching PostgreSQL source archive", "sha256": "dd27f2b3c59e73ed14aa3324901242bf69a032a6347805f274e6260322d42979"}, {"url": "/docs/17/gssapi-auth.html", "path": "gssapi-auth.html", "label": "PostgreSQL 17 English manual", "sha256": "8ff2953089d8bb969deb356244f5fa7540fd521d0c0f004eef2019184d5e6478"}, {"url": "/docs/17/auth-pg-hba-conf.html", "path": "auth-pg-hba-conf.html", "label": "PostgreSQL 17 English manual", "sha256": "00c7a7c25d46aa1b2f24cd744cd4990ca4218cfafed2a4cab8c1dc1092090bba"}], "sections": [], "signature": "", "attributes": {"method": "gss", "inventory": "User-visible source authentication method", "configuration": "pg_hba.conf"}, "description": ["Use GSSAPI to authenticate the user. This is only available for TCP/IP connections. See Section 20.6 for details. It can be used in conjunction with GSSAPI encryption."], "manual_html": "<div class=\"sect1\" id=\"GSSAPI-AUTH\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h2 class=\"title\">20.6.\u00a0GSSAPI Authentication </h2>\n</div>\n</div>\n</div>\n<p><span class=\"productname\">GSSAPI</span> is an industry-standard protocol for secure authentication defined in <a class=\"ulink\" href=\"https://datatracker.ietf.org/doc/html/rfc2743\">RFC 2743</a>. <span class=\"productname\">PostgreSQL</span> supports <span class=\"productname\">GSSAPI</span> for authentication, communications encryption, or both. <span class=\"productname\">GSSAPI</span> provides automatic authentication (single sign-on) for systems that support it. The authentication itself is secure. If <span class=\"productname\">GSSAPI</span> encryption or SSL encryption is used, the data sent along the database connection will be encrypted; otherwise, it will not.</p>\n<p>GSSAPI support has to be enabled when <span class=\"productname\">PostgreSQL</span> is built; see <a class=\"xref\" href=\"/docs/17/installation.html\" title=\"Chapter\u00a017.\u00a0Installation from Source Code\">Chapter\u00a017</a> for more information.</p>\n<p>When <span class=\"productname\">GSSAPI</span> uses <span class=\"productname\">Kerberos</span>, it uses a standard service principal (authentication identity) name in the format <code class=\"literal\"><em class=\"replaceable\"><code>servicename</code></em>/<em class=\"replaceable\"><code>hostname</code></em>@<em class=\"replaceable\"><code>realm</code></em></code>. The principal name used by a particular installation is not encoded in the <span class=\"productname\">PostgreSQL</span> server in any way; rather it is specified in the <em class=\"firstterm\">keytab</em> file that the server reads to determine its identity. If multiple principals are listed in the keytab file, the server will accept any one of them. The server's realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the server.</p>\n<p>When connecting, the client must know the principal name of the server it intends to connect to. The <em class=\"replaceable\"><code>servicename</code></em> part of the principal is ordinarily <code class=\"literal\">postgres</code>, but another value can be selected via <span class=\"application\">libpq</span>'s <a class=\"xref\" href=\"/docs/17/libpq-connect.html#LIBPQ-CONNECT-KRBSRVNAME\">krbsrvname</a> connection parameter. The <em class=\"replaceable\"><code>hostname</code></em> part is the fully qualified host name that <span class=\"application\">libpq</span> is told to connect to. The realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the client.</p>\n<p>The client will also have a principal name for its own identity (and it must have a valid ticket for this principal). To use <span class=\"productname\">GSSAPI</span> for authentication, the client principal must be associated with a <span class=\"productname\">PostgreSQL</span> database user name. The <code class=\"filename\">pg_ident.conf</code> configuration file can be used to map principals to user names; for example, <code class=\"literal\">pgusername@realm</code> could be mapped to just <code class=\"literal\">pgusername</code>. Alternatively, you can use the full <code class=\"literal\">username@realm</code> principal as the role name in <span class=\"productname\">PostgreSQL</span> without any mapping.</p>\n<p><span class=\"productname\">PostgreSQL</span> also supports mapping client principals to user names by just stripping the realm from the principal. This method is supported for backwards compatibility and is strongly discouraged as it is then impossible to distinguish different users with the same user name but coming from different realms. To enable this, set <code class=\"literal\">include_realm</code> to 0. For simple single-realm installations, doing that combined with setting the <code class=\"literal\">krb_realm</code> parameter (which checks that the principal's realm matches exactly what is in the <code class=\"literal\">krb_realm</code> parameter) is still secure; but this is a less capable approach compared to specifying an explicit mapping in <code class=\"filename\">pg_ident.conf</code>.</p>\n<p>The location of the server's keytab file is specified by the <a class=\"xref\" href=\"/docs/17/runtime-config-connection.html#GUC-KRB-SERVER-KEYFILE\">krb_server_keyfile</a> configuration parameter. For security reasons, it is recommended to use a separate keytab just for the <span class=\"productname\">PostgreSQL</span> server rather than allowing the server to read the system keytab file. Make sure that your server keytab file is readable (and preferably only readable, not writable) by the <span class=\"productname\">PostgreSQL</span> server account. (See also <a class=\"xref\" href=\"/docs/17/postgres-user.html\" title=\"18.1.\u00a0The PostgreSQL User Account\">Section\u00a018.1</a>.)</p>\n<p>The keytab file is generated using the Kerberos software; see the Kerberos documentation for details. The following example shows doing this using the <span class=\"application\">kadmin</span> tool of MIT Kerberos:</p>\n<pre class=\"screen\"><code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>addprinc -randkey postgres/server.my.domain.org</code></strong>\n<code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>ktadd -k krb5.keytab postgres/server.my.domain.org</code></strong>\n</pre>\n<p>The following authentication options are supported for the <span class=\"productname\">GSSAPI</span> authentication method:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">include_realm</code></span></dt>\n<dd>\n<p>If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping (<a class=\"xref\" href=\"/docs/17/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a>). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless <code class=\"literal\">krb_realm</code> is also used. It is recommended to leave <code class=\"literal\">include_realm</code> set to the default (1) and to provide an explicit mapping in <code class=\"filename\">pg_ident.conf</code> to convert principal names to <span class=\"productname\">PostgreSQL</span> user names.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">map</code></span></dt>\n<dd>\n<p>Allows mapping from client principals to database user names. See <a class=\"xref\" href=\"/docs/17/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a> for details. For a GSSAPI/Kerberos principal, such as <code class=\"literal\">username@EXAMPLE.COM</code> (or, less commonly, <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>), the user name used for mapping is <code class=\"literal\">username@EXAMPLE.COM</code> (or <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>, respectively), unless <code class=\"literal\">include_realm</code> has been set to 0, in which case <code class=\"literal\">username</code> (or <code class=\"literal\">username/hostbased</code>) is what is seen as the system user name when mapping.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">krb_realm</code></span></dt>\n<dd>\n<p>Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done.</p>\n</dd>\n</dl>\n</div>\n<p>In addition to these settings, which can be different for different <code class=\"filename\">pg_hba.conf</code> entries, there is the server-wide <a class=\"xref\" href=\"/docs/17/runtime-config-connection.html#GUC-KRB-CASEINS-USERS\">krb_caseins_users</a> configuration parameter. If that is set to true, client principals are matched to user map entries case-insensitively. <code class=\"literal\">krb_realm</code>, if set, is also matched case-insensitively.</p>\n</div>", "manual_path": "/docs/17/gssapi-auth.html", "comparison_data": {"method": "gss", "documented_option_names": ["include_realm", "krb_realm", "map"]}, "comparison_hash": "c58b84e18bba9d75d595bab34b326eb6a8580a80636f79642c4af8843e7123cf"}, "18": {"facts": [{"label": "Method", "value": "gss"}, {"label": "Configuration", "value": "pg_hba.conf"}, {"label": "Inventory", "value": "User-visible source authentication method"}], "tables": [{"key": "method-options", "rows": [{"name": "include_realm", "description": "If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping ( Section 20.2 ). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless krb_realm is also used. It is recommended to leave include_realm set to the default (1) and to provide an explicit mapping in pg_ident.conf to convert principal names to PostgreSQL user names."}, {"name": "map", "description": "Allows mapping from client principals to database user names. See Section 20.2 for details. For a GSSAPI/Kerberos principal, such as username@EXAMPLE.COM (or, less commonly, username/hostbased@EXAMPLE.COM ), the user name used for mapping is username@EXAMPLE.COM (or username/hostbased@EXAMPLE.COM , respectively), unless include_realm has been set to 0, in which case username (or username/hostbased ) is what is seen as the system user name when mapping."}, {"name": "krb_realm", "description": "Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done."}], "title": "Documented method options and alternatives", "columns": [{"key": "name", "label": "Option or term"}, {"key": "description", "label": "Meaning"}]}], "aliases": [], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "18.6", "major": "18", "channel": "stable", "revision": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f", "catalog_fingerprint": "65c93d6048ef30e61023a84f9680fa6a92b1c383b7eb226741170077eb078502"}, "sources": [{"url": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "Matching PostgreSQL source archive", "sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, {"url": "/docs/18/gssapi-auth.html", "path": "gssapi-auth.html", "label": "PostgreSQL 18 English manual", "sha256": "00da5d918d0d4f101749a389bcef7ae273436d43ddf22dcb5d38d2ec1d7c8735"}, {"url": "/docs/18/auth-pg-hba-conf.html", "path": "auth-pg-hba-conf.html", "label": "PostgreSQL 18 English manual", "sha256": "6340d4abea2e0a3482afc31bcd1599a0fa10dc28a6f1e05d79ba831e2dd0b4c9"}], "sections": [], "signature": "", "attributes": {"method": "gss", "inventory": "User-visible source authentication method", "configuration": "pg_hba.conf"}, "description": ["Use GSSAPI to authenticate the user. This is only available for TCP/IP connections. See Section 20.6 for details. It can be used in conjunction with GSSAPI encryption."], "manual_html": "<div class=\"sect1\" id=\"GSSAPI-AUTH\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h2 class=\"title\">20.6.\u00a0GSSAPI Authentication </h2>\n</div>\n</div>\n</div>\n<p><span class=\"productname\">GSSAPI</span> is an industry-standard protocol for secure authentication defined in <a class=\"ulink\" href=\"https://datatracker.ietf.org/doc/html/rfc2743\">RFC 2743</a>. <span class=\"productname\">PostgreSQL</span> supports <span class=\"productname\">GSSAPI</span> for authentication, communications encryption, or both. <span class=\"productname\">GSSAPI</span> provides automatic authentication (single sign-on) for systems that support it. The authentication itself is secure. If <span class=\"productname\">GSSAPI</span> encryption or SSL encryption is used, the data sent along the database connection will be encrypted; otherwise, it will not.</p>\n<p>GSSAPI support has to be enabled when <span class=\"productname\">PostgreSQL</span> is built; see <a class=\"xref\" href=\"/docs/18/installation.html\" title=\"Chapter\u00a017.\u00a0Installation from Source Code\">Chapter\u00a017</a> for more information.</p>\n<p>When <span class=\"productname\">GSSAPI</span> uses <span class=\"productname\">Kerberos</span>, it uses a standard service principal (authentication identity) name in the format <code class=\"literal\"><em class=\"replaceable\"><code>servicename</code></em>/<em class=\"replaceable\"><code>hostname</code></em>@<em class=\"replaceable\"><code>realm</code></em></code>. The principal name used by a particular installation is not encoded in the <span class=\"productname\">PostgreSQL</span> server in any way; rather it is specified in the <em class=\"firstterm\">keytab</em> file that the server reads to determine its identity. If multiple principals are listed in the keytab file, the server will accept any one of them. The server's realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the server.</p>\n<p>When connecting, the client must know the principal name of the server it intends to connect to. The <em class=\"replaceable\"><code>servicename</code></em> part of the principal is ordinarily <code class=\"literal\">postgres</code>, but another value can be selected via <span class=\"application\">libpq</span>'s <a class=\"xref\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNECT-KRBSRVNAME\">krbsrvname</a> connection parameter. The <em class=\"replaceable\"><code>hostname</code></em> part is the fully qualified host name that <span class=\"application\">libpq</span> is told to connect to. The realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the client.</p>\n<p>The client will also have a principal name for its own identity (and it must have a valid ticket for this principal). To use <span class=\"productname\">GSSAPI</span> for authentication, the client principal must be associated with a <span class=\"productname\">PostgreSQL</span> database user name. The <code class=\"filename\">pg_ident.conf</code> configuration file can be used to map principals to user names; for example, <code class=\"literal\">pgusername@realm</code> could be mapped to just <code class=\"literal\">pgusername</code>. Alternatively, you can use the full <code class=\"literal\">username@realm</code> principal as the role name in <span class=\"productname\">PostgreSQL</span> without any mapping.</p>\n<p><span class=\"productname\">PostgreSQL</span> also supports mapping client principals to user names by just stripping the realm from the principal. This method is supported for backwards compatibility and is strongly discouraged as it is then impossible to distinguish different users with the same user name but coming from different realms. To enable this, set <code class=\"literal\">include_realm</code> to 0. For simple single-realm installations, doing that combined with setting the <code class=\"literal\">krb_realm</code> parameter (which checks that the principal's realm matches exactly what is in the <code class=\"literal\">krb_realm</code> parameter) is still secure; but this is a less capable approach compared to specifying an explicit mapping in <code class=\"filename\">pg_ident.conf</code>.</p>\n<p>The location of the server's keytab file is specified by the <a class=\"xref\" href=\"/docs/18/runtime-config-connection.html#GUC-KRB-SERVER-KEYFILE\">krb_server_keyfile</a> configuration parameter. For security reasons, it is recommended to use a separate keytab just for the <span class=\"productname\">PostgreSQL</span> server rather than allowing the server to read the system keytab file. Make sure that your server keytab file is readable (and preferably only readable, not writable) by the <span class=\"productname\">PostgreSQL</span> server account. (See also <a class=\"xref\" href=\"/docs/18/postgres-user.html\" title=\"18.1.\u00a0The PostgreSQL User Account\">Section\u00a018.1</a>.)</p>\n<p>The keytab file is generated using the Kerberos software; see the Kerberos documentation for details. The following example shows doing this using the <span class=\"application\">kadmin</span> tool of MIT Kerberos:</p>\n<pre class=\"screen\"><code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>addprinc -randkey postgres/server.my.domain.org</code></strong>\n<code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>ktadd -k krb5.keytab postgres/server.my.domain.org</code></strong>\n</pre>\n<p>The following authentication options are supported for the <span class=\"productname\">GSSAPI</span> authentication method:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">include_realm</code></span></dt>\n<dd>\n<p>If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping (<a class=\"xref\" href=\"/docs/18/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a>). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless <code class=\"literal\">krb_realm</code> is also used. It is recommended to leave <code class=\"literal\">include_realm</code> set to the default (1) and to provide an explicit mapping in <code class=\"filename\">pg_ident.conf</code> to convert principal names to <span class=\"productname\">PostgreSQL</span> user names.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">map</code></span></dt>\n<dd>\n<p>Allows mapping from client principals to database user names. See <a class=\"xref\" href=\"/docs/18/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a> for details. For a GSSAPI/Kerberos principal, such as <code class=\"literal\">username@EXAMPLE.COM</code> (or, less commonly, <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>), the user name used for mapping is <code class=\"literal\">username@EXAMPLE.COM</code> (or <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>, respectively), unless <code class=\"literal\">include_realm</code> has been set to 0, in which case <code class=\"literal\">username</code> (or <code class=\"literal\">username/hostbased</code>) is what is seen as the system user name when mapping.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">krb_realm</code></span></dt>\n<dd>\n<p>Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done.</p>\n</dd>\n</dl>\n</div>\n<p>In addition to these settings, which can be different for different <code class=\"filename\">pg_hba.conf</code> entries, there is the server-wide <a class=\"xref\" href=\"/docs/18/runtime-config-connection.html#GUC-KRB-CASEINS-USERS\">krb_caseins_users</a> configuration parameter. If that is set to true, client principals are matched to user map entries case-insensitively. <code class=\"literal\">krb_realm</code>, if set, is also matched case-insensitively.</p>\n</div>", "manual_path": "/docs/18/gssapi-auth.html", "comparison_data": {"method": "gss", "documented_option_names": ["include_realm", "krb_realm", "map"]}, "comparison_hash": "c58b84e18bba9d75d595bab34b326eb6a8580a80636f79642c4af8843e7123cf"}, "19": {"facts": [{"label": "Method", "value": "gss"}, {"label": "Configuration", "value": "pg_hba.conf"}, {"label": "Inventory", "value": "User-visible source authentication method"}], "tables": [{"key": "method-options", "rows": [{"name": "include_realm", "description": "If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping ( Section 20.2 ). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless krb_realm is also used. It is recommended to leave include_realm set to the default (1) and to provide an explicit mapping in pg_ident.conf to convert principal names to PostgreSQL user names."}, {"name": "map", "description": "Allows mapping from client principals to database user names. See Section 20.2 for details. For a GSSAPI/Kerberos principal, such as username@EXAMPLE.COM (or, less commonly, username/hostbased@EXAMPLE.COM ), the user name used for mapping is username@EXAMPLE.COM (or username/hostbased@EXAMPLE.COM , respectively), unless include_realm has been set to 0, in which case username (or username/hostbased ) is what is seen as the system user name when mapping."}, {"name": "krb_realm", "description": "Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done."}], "title": "Documented method options and alternatives", "columns": [{"key": "name", "label": "Option or term"}, {"key": "description", "label": "Meaning"}]}], "aliases": [], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v19beta4/postgresql-19beta4.tar.bz2", "label": "19beta4", "major": "19", "channel": "preview", "revision": "83157ee9c599d03b2f7a3d73ef3a56ec24e0e79cc2b3501a64d1364f56398c86", "source_sha256": "83157ee9c599d03b2f7a3d73ef3a56ec24e0e79cc2b3501a64d1364f56398c86", "catalog_fingerprint": "62fbf1a3689dbe8bf7e6b3372cfe6fbf867581427b3858a94c8419b77a4d2d1d"}, "sources": [{"url": "https://ftp.postgresql.org/pub/source/v19beta4/postgresql-19beta4.tar.bz2", "label": "Matching PostgreSQL source archive", "sha256": "83157ee9c599d03b2f7a3d73ef3a56ec24e0e79cc2b3501a64d1364f56398c86"}, {"url": "/docs/19/gssapi-auth.html", "path": "gssapi-auth.html", "label": "PostgreSQL 19 English manual", "sha256": "8b7d1169b27c1afaf1dffc8a1b3b43981e0463279df845e8f1a559ba776f00ce"}, {"url": "/docs/19/auth-pg-hba-conf.html", "path": "auth-pg-hba-conf.html", "label": "PostgreSQL 19 English manual", "sha256": "d05e9155d5388148c2c680ff208b62c6b3b0b1c30f302ada5ab4befec36c19b7"}], "sections": [], "signature": "", "attributes": {"method": "gss", "inventory": "User-visible source authentication method", "configuration": "pg_hba.conf"}, "description": ["Use GSSAPI to authenticate the user. This is only available for TCP/IP connections. See Section 20.6 for details. It can be used in conjunction with GSSAPI encryption."], "manual_html": "<div class=\"sect1\" id=\"GSSAPI-AUTH\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h2 class=\"title\">20.6.\u00a0GSSAPI Authentication </h2>\n</div>\n</div>\n</div>\n<p><span class=\"productname\">GSSAPI</span> is an industry-standard protocol for secure authentication defined in <a class=\"ulink\" href=\"https://datatracker.ietf.org/doc/html/rfc2743\">RFC 2743</a>. <span class=\"productname\">PostgreSQL</span> supports <span class=\"productname\">GSSAPI</span> for authentication, communications encryption, or both. <span class=\"productname\">GSSAPI</span> provides automatic authentication (single sign-on) for systems that support it. The authentication itself is secure. If <span class=\"productname\">GSSAPI</span> encryption or SSL encryption is used, the data sent along the database connection will be encrypted; otherwise, it will not.</p>\n<p>GSSAPI support has to be enabled when <span class=\"productname\">PostgreSQL</span> is built; see <a class=\"xref\" href=\"/docs/19/installation.html\" title=\"Chapter\u00a017.\u00a0Installation from Source Code\">Chapter\u00a017</a> for more information.</p>\n<p>When <span class=\"productname\">GSSAPI</span> uses <span class=\"productname\">Kerberos</span>, it uses a standard service principal (authentication identity) name in the format <code class=\"literal\"><em class=\"replaceable\"><code>servicename</code></em>/<em class=\"replaceable\"><code>hostname</code></em>@<em class=\"replaceable\"><code>realm</code></em></code>. The principal name used by a particular installation is not encoded in the <span class=\"productname\">PostgreSQL</span> server in any way; rather it is specified in the <em class=\"firstterm\">keytab</em> file that the server reads to determine its identity. If multiple principals are listed in the keytab file, the server will accept any one of them. The server's realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the server.</p>\n<p>When connecting, the client must know the principal name of the server it intends to connect to. The <em class=\"replaceable\"><code>servicename</code></em> part of the principal is ordinarily <code class=\"literal\">postgres</code>, but another value can be selected via <span class=\"application\">libpq</span>'s <a class=\"xref\" href=\"/docs/19/libpq-connect.html#LIBPQ-CONNECT-KRBSRVNAME\">krbsrvname</a> connection parameter. The <em class=\"replaceable\"><code>hostname</code></em> part is the fully qualified host name that <span class=\"application\">libpq</span> is told to connect to. The realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the client.</p>\n<p>The client will also have a principal name for its own identity (and it must have a valid ticket for this principal). To use <span class=\"productname\">GSSAPI</span> for authentication, the client principal must be associated with a <span class=\"productname\">PostgreSQL</span> database user name. The <code class=\"filename\">pg_ident.conf</code> configuration file can be used to map principals to user names; for example, <code class=\"literal\">pgusername@realm</code> could be mapped to just <code class=\"literal\">pgusername</code>. Alternatively, you can use the full <code class=\"literal\">username@realm</code> principal as the role name in <span class=\"productname\">PostgreSQL</span> without any mapping.</p>\n<p><span class=\"productname\">PostgreSQL</span> also supports mapping client principals to user names by just stripping the realm from the principal. This method is supported for backwards compatibility and is strongly discouraged as it is then impossible to distinguish different users with the same user name but coming from different realms. To enable this, set <code class=\"literal\">include_realm</code> to 0. For simple single-realm installations, doing that combined with setting the <code class=\"literal\">krb_realm</code> parameter (which checks that the principal's realm matches exactly what is in the <code class=\"literal\">krb_realm</code> parameter) is still secure; but this is a less capable approach compared to specifying an explicit mapping in <code class=\"filename\">pg_ident.conf</code>.</p>\n<p>The location of the server's keytab file is specified by the <a class=\"xref\" href=\"/docs/19/runtime-config-connection.html#GUC-KRB-SERVER-KEYFILE\">krb_server_keyfile</a> configuration parameter. For security reasons, it is recommended to use a separate keytab just for the <span class=\"productname\">PostgreSQL</span> server rather than allowing the server to read the system keytab file. Make sure that your server keytab file is readable (and preferably only readable, not writable) by the <span class=\"productname\">PostgreSQL</span> server account. (See also <a class=\"xref\" href=\"/docs/19/postgres-user.html\" title=\"18.1.\u00a0The PostgreSQL User Account\">Section\u00a018.1</a>.)</p>\n<p>The keytab file is generated using the Kerberos software; see the Kerberos documentation for details. The following example shows doing this using the <span class=\"application\">kadmin</span> tool of MIT Kerberos:</p>\n<pre class=\"screen\"><code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>addprinc -randkey postgres/server.my.domain.org</code></strong>\n<code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>ktadd -k krb5.keytab postgres/server.my.domain.org</code></strong>\n</pre>\n<p>The following authentication options are supported for the <span class=\"productname\">GSSAPI</span> authentication method:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">include_realm</code></span></dt>\n<dd>\n<p>If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping (<a class=\"xref\" href=\"/docs/19/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a>). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless <code class=\"literal\">krb_realm</code> is also used. It is recommended to leave <code class=\"literal\">include_realm</code> set to the default (1) and to provide an explicit mapping in <code class=\"filename\">pg_ident.conf</code> to convert principal names to <span class=\"productname\">PostgreSQL</span> user names.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">map</code></span></dt>\n<dd>\n<p>Allows mapping from client principals to database user names. See <a class=\"xref\" href=\"/docs/19/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a> for details. For a GSSAPI/Kerberos principal, such as <code class=\"literal\">username@EXAMPLE.COM</code> (or, less commonly, <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>), the user name used for mapping is <code class=\"literal\">username@EXAMPLE.COM</code> (or <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>, respectively), unless <code class=\"literal\">include_realm</code> has been set to 0, in which case <code class=\"literal\">username</code> (or <code class=\"literal\">username/hostbased</code>) is what is seen as the system user name when mapping.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">krb_realm</code></span></dt>\n<dd>\n<p>Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done.</p>\n</dd>\n</dl>\n</div>\n<p>In addition to these settings, which can be different for different <code class=\"filename\">pg_hba.conf</code> entries, there is the server-wide <a class=\"xref\" href=\"/docs/19/runtime-config-connection.html#GUC-KRB-CASEINS-USERS\">krb_caseins_users</a> configuration parameter. If that is set to true, client principals are matched to user map entries case-insensitively. <code class=\"literal\">krb_realm</code>, if set, is also matched case-insensitively.</p>\n</div>", "manual_path": "/docs/19/gssapi-auth.html", "comparison_data": {"method": "gss", "documented_option_names": ["include_realm", "krb_realm", "map"]}, "comparison_hash": "c58b84e18bba9d75d595bab34b326eb6a8580a80636f79642c4af8843e7123cf"}, "20": {"facts": [{"label": "Method", "value": "gss"}, {"label": "Configuration", "value": "pg_hba.conf"}, {"label": "Inventory", "value": "User-visible source authentication method"}], "tables": [{"key": "method-options", "rows": [{"name": "include_realm", "description": "If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping ( Section 20.2 ). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless krb_realm is also used. It is recommended to leave include_realm set to the default (1) and to provide an explicit mapping in pg_ident.conf to convert principal names to PostgreSQL user names."}, {"name": "map", "description": "Allows mapping from client principals to database user names. See Section 20.2 for details. For a GSSAPI/Kerberos principal, such as username@EXAMPLE.COM (or, less commonly, username/hostbased@EXAMPLE.COM ), the user name used for mapping is username@EXAMPLE.COM (or username/hostbased@EXAMPLE.COM , respectively), unless include_realm has been set to 0, in which case username (or username/hostbased ) is what is seen as the system user name when mapping."}, {"name": "krb_realm", "description": "Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done."}], "title": "Documented method options and alternatives", "columns": [{"key": "name", "label": "Option or term"}, {"key": "description", "label": "Meaning"}]}], "aliases": [], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.tar.bz2", "label": "20devel", "major": "20", "channel": "devel", "revision": "4d3346909b201ac1648232cf290462a7070c119326f56196f1f0253ed80fae41", "source_sha256": "4d3346909b201ac1648232cf290462a7070c119326f56196f1f0253ed80fae41", "catalog_fingerprint": "398fbb9f262264053c02fbf79f88be0a6770c1473faa6ecd5931d6ec41b8258b", "source_snapshot_utc": "26-Sep-2026 20:22"}, "sources": [{"url": "https://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.tar.bz2", "label": "Matching PostgreSQL source archive", "sha256": "4d3346909b201ac1648232cf290462a7070c119326f56196f1f0253ed80fae41"}, {"url": "/docs/devel/gssapi-auth.html", "path": "gssapi-auth.html", "label": "PostgreSQL 20 English manual", "sha256": "cb2e8608aa069b2726adbd6d204ebfbc893a85e1f6d72fdd35e4a7175943e942"}, {"url": "/docs/devel/auth-pg-hba-conf.html", "path": "auth-pg-hba-conf.html", "label": "PostgreSQL 20 English manual", "sha256": "cf2069461da3eec62f6fb4e3df8e46fd69ff4b3a2ad059eec355cee256d7996e"}], "sections": [], "signature": "", "attributes": {"method": "gss", "inventory": "User-visible source authentication method", "configuration": "pg_hba.conf"}, "description": ["Use GSSAPI to authenticate the user. This is only available for TCP/IP connections. See Section 20.6 for details. It can be used in conjunction with GSSAPI encryption."], "manual_html": "<div class=\"sect1\" id=\"GSSAPI-AUTH\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h2 class=\"title\">20.6.\u00a0GSSAPI Authentication </h2>\n</div>\n</div>\n</div>\n<p><span class=\"productname\">GSSAPI</span> is an industry-standard protocol for secure authentication defined in <a class=\"ulink\" href=\"https://datatracker.ietf.org/doc/html/rfc2743\">RFC 2743</a>. <span class=\"productname\">PostgreSQL</span> supports <span class=\"productname\">GSSAPI</span> for authentication, communications encryption, or both. <span class=\"productname\">GSSAPI</span> provides automatic authentication (single sign-on) for systems that support it. The authentication itself is secure. If <span class=\"productname\">GSSAPI</span> encryption or SSL encryption is used, the data sent along the database connection will be encrypted; otherwise, it will not.</p>\n<p>GSSAPI support has to be enabled when <span class=\"productname\">PostgreSQL</span> is built; see <a class=\"xref\" href=\"/docs/devel/installation.html\" title=\"Chapter\u00a017.\u00a0Installation from Source Code\">Chapter\u00a017</a> for more information.</p>\n<p>When <span class=\"productname\">GSSAPI</span> uses <span class=\"productname\">Kerberos</span>, it uses a standard service principal (authentication identity) name in the format <code class=\"literal\"><em class=\"replaceable\"><code>servicename</code></em>/<em class=\"replaceable\"><code>hostname</code></em>@<em class=\"replaceable\"><code>realm</code></em></code>. The principal name used by a particular installation is not encoded in the <span class=\"productname\">PostgreSQL</span> server in any way; rather it is specified in the <em class=\"firstterm\">keytab</em> file that the server reads to determine its identity. If multiple principals are listed in the keytab file, the server will accept any one of them. The server's realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the server.</p>\n<p>When connecting, the client must know the principal name of the server it intends to connect to. The <em class=\"replaceable\"><code>servicename</code></em> part of the principal is ordinarily <code class=\"literal\">postgres</code>, but another value can be selected via <span class=\"application\">libpq</span>'s <a class=\"xref\" href=\"/docs/devel/libpq-connect.html#LIBPQ-CONNECT-KRBSRVNAME\">krbsrvname</a> connection parameter. The <em class=\"replaceable\"><code>hostname</code></em> part is the fully qualified host name that <span class=\"application\">libpq</span> is told to connect to. The realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the client.</p>\n<p>The client will also have a principal name for its own identity (and it must have a valid ticket for this principal). To use <span class=\"productname\">GSSAPI</span> for authentication, the client principal must be associated with a <span class=\"productname\">PostgreSQL</span> database user name. The <code class=\"filename\">pg_ident.conf</code> configuration file can be used to map principals to user names; for example, <code class=\"literal\">pgusername@realm</code> could be mapped to just <code class=\"literal\">pgusername</code>. Alternatively, you can use the full <code class=\"literal\">username@realm</code> principal as the role name in <span class=\"productname\">PostgreSQL</span> without any mapping.</p>\n<p><span class=\"productname\">PostgreSQL</span> also supports mapping client principals to user names by just stripping the realm from the principal. This method is supported for backwards compatibility and is strongly discouraged as it is then impossible to distinguish different users with the same user name but coming from different realms. To enable this, set <code class=\"literal\">include_realm</code> to 0. For simple single-realm installations, doing that combined with setting the <code class=\"literal\">krb_realm</code> parameter (which checks that the principal's realm matches exactly what is in the <code class=\"literal\">krb_realm</code> parameter) is still secure; but this is a less capable approach compared to specifying an explicit mapping in <code class=\"filename\">pg_ident.conf</code>.</p>\n<p>The location of the server's keytab file is specified by the <a class=\"xref\" href=\"/docs/devel/runtime-config-connection.html#GUC-KRB-SERVER-KEYFILE\">krb_server_keyfile</a> configuration parameter. For security reasons, it is recommended to use a separate keytab just for the <span class=\"productname\">PostgreSQL</span> server rather than allowing the server to read the system keytab file. Make sure that your server keytab file is readable (and preferably only readable, not writable) by the <span class=\"productname\">PostgreSQL</span> server account. (See also <a class=\"xref\" href=\"/docs/devel/postgres-user.html\" title=\"18.1.\u00a0The PostgreSQL User Account\">Section\u00a018.1</a>.)</p>\n<p>The keytab file is generated using the Kerberos software; see the Kerberos documentation for details. The following example shows doing this using the <span class=\"application\">kadmin</span> tool of MIT Kerberos:</p>\n<pre class=\"screen\"><code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>addprinc -randkey postgres/server.my.domain.org</code></strong>\n<code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>ktadd -k krb5.keytab postgres/server.my.domain.org</code></strong>\n</pre>\n<p>The following authentication options are supported for the <span class=\"productname\">GSSAPI</span> authentication method:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">include_realm</code></span></dt>\n<dd>\n<p>If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping (<a class=\"xref\" href=\"/docs/devel/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a>). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless <code class=\"literal\">krb_realm</code> is also used. It is recommended to leave <code class=\"literal\">include_realm</code> set to the default (1) and to provide an explicit mapping in <code class=\"filename\">pg_ident.conf</code> to convert principal names to <span class=\"productname\">PostgreSQL</span> user names.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">map</code></span></dt>\n<dd>\n<p>Allows mapping from client principals to database user names. See <a class=\"xref\" href=\"/docs/devel/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a> for details. For a GSSAPI/Kerberos principal, such as <code class=\"literal\">username@EXAMPLE.COM</code> (or, less commonly, <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>), the user name used for mapping is <code class=\"literal\">username@EXAMPLE.COM</code> (or <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>, respectively), unless <code class=\"literal\">include_realm</code> has been set to 0, in which case <code class=\"literal\">username</code> (or <code class=\"literal\">username/hostbased</code>) is what is seen as the system user name when mapping.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">krb_realm</code></span></dt>\n<dd>\n<p>Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done.</p>\n</dd>\n</dl>\n</div>\n<p>In addition to these settings, which can be different for different <code class=\"filename\">pg_hba.conf</code> entries, there is the server-wide <a class=\"xref\" href=\"/docs/devel/runtime-config-connection.html#GUC-KRB-CASEINS-USERS\">krb_caseins_users</a> configuration parameter. If that is set to true, client principals are matched to user map entries case-insensitively. <code class=\"literal\">krb_realm</code>, if set, is also matched case-insensitively.</p>\n</div>", "manual_path": "/docs/devel/gssapi-auth.html", "comparison_data": {"method": "gss", "documented_option_names": ["include_realm", "krb_realm", "map"]}, "comparison_hash": "c58b84e18bba9d75d595bab34b326eb6a8580a80636f79642c4af8843e7123cf"}}}, "snapshot": {"facts": [{"label": "Method", "value": "gss"}, {"label": "Configuration", "value": "pg_hba.conf"}, {"label": "Inventory", "value": "User-visible source authentication method"}], "tables": [{"key": "method-options", "rows": [{"name": "include_realm", "description": "If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping ( Section 20.2 ). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless krb_realm is also used. It is recommended to leave include_realm set to the default (1) and to provide an explicit mapping in pg_ident.conf to convert principal names to PostgreSQL user names."}, {"name": "map", "description": "Allows mapping from client principals to database user names. See Section 20.2 for details. For a GSSAPI/Kerberos principal, such as username@EXAMPLE.COM (or, less commonly, username/hostbased@EXAMPLE.COM ), the user name used for mapping is username@EXAMPLE.COM (or username/hostbased@EXAMPLE.COM , respectively), unless include_realm has been set to 0, in which case username (or username/hostbased ) is what is seen as the system user name when mapping."}, {"name": "krb_realm", "description": "Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done."}], "title": "Documented method options and alternatives", "columns": [{"key": "name", "label": "Option or term"}, {"key": "description", "label": "Meaning"}]}], "aliases": [], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "18.6", "major": "18", "channel": "stable", "revision": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f", "catalog_fingerprint": "65c93d6048ef30e61023a84f9680fa6a92b1c383b7eb226741170077eb078502"}, "sources": [{"url": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "Matching PostgreSQL source archive", "sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, {"url": "/docs/18/gssapi-auth.html", "path": "gssapi-auth.html", "label": "PostgreSQL 18 English manual", "sha256": "00da5d918d0d4f101749a389bcef7ae273436d43ddf22dcb5d38d2ec1d7c8735"}, {"url": "/docs/18/auth-pg-hba-conf.html", "path": "auth-pg-hba-conf.html", "label": "PostgreSQL 18 English manual", "sha256": "6340d4abea2e0a3482afc31bcd1599a0fa10dc28a6f1e05d79ba831e2dd0b4c9"}], "sections": [], "signature": "", "attributes": {"method": "gss", "inventory": "User-visible source authentication method", "configuration": "pg_hba.conf"}, "description": ["Use GSSAPI to authenticate the user. This is only available for TCP/IP connections. See Section 20.6 for details. It can be used in conjunction with GSSAPI encryption."], "manual_html": "<div class=\"sect1\" id=\"GSSAPI-AUTH\">\n<div class=\"titlepage\">\n<div>\n<div>\n<h2 class=\"title\">20.6.\u00a0GSSAPI Authentication </h2>\n</div>\n</div>\n</div>\n<p><span class=\"productname\">GSSAPI</span> is an industry-standard protocol for secure authentication defined in <a class=\"ulink\" href=\"https://datatracker.ietf.org/doc/html/rfc2743\">RFC 2743</a>. <span class=\"productname\">PostgreSQL</span> supports <span class=\"productname\">GSSAPI</span> for authentication, communications encryption, or both. <span class=\"productname\">GSSAPI</span> provides automatic authentication (single sign-on) for systems that support it. The authentication itself is secure. If <span class=\"productname\">GSSAPI</span> encryption or SSL encryption is used, the data sent along the database connection will be encrypted; otherwise, it will not.</p>\n<p>GSSAPI support has to be enabled when <span class=\"productname\">PostgreSQL</span> is built; see <a class=\"xref\" href=\"/docs/18/installation.html\" title=\"Chapter\u00a017.\u00a0Installation from Source Code\">Chapter\u00a017</a> for more information.</p>\n<p>When <span class=\"productname\">GSSAPI</span> uses <span class=\"productname\">Kerberos</span>, it uses a standard service principal (authentication identity) name in the format <code class=\"literal\"><em class=\"replaceable\"><code>servicename</code></em>/<em class=\"replaceable\"><code>hostname</code></em>@<em class=\"replaceable\"><code>realm</code></em></code>. The principal name used by a particular installation is not encoded in the <span class=\"productname\">PostgreSQL</span> server in any way; rather it is specified in the <em class=\"firstterm\">keytab</em> file that the server reads to determine its identity. If multiple principals are listed in the keytab file, the server will accept any one of them. The server's realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the server.</p>\n<p>When connecting, the client must know the principal name of the server it intends to connect to. The <em class=\"replaceable\"><code>servicename</code></em> part of the principal is ordinarily <code class=\"literal\">postgres</code>, but another value can be selected via <span class=\"application\">libpq</span>'s <a class=\"xref\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNECT-KRBSRVNAME\">krbsrvname</a> connection parameter. The <em class=\"replaceable\"><code>hostname</code></em> part is the fully qualified host name that <span class=\"application\">libpq</span> is told to connect to. The realm name is the preferred realm specified in the Kerberos configuration file(s) accessible to the client.</p>\n<p>The client will also have a principal name for its own identity (and it must have a valid ticket for this principal). To use <span class=\"productname\">GSSAPI</span> for authentication, the client principal must be associated with a <span class=\"productname\">PostgreSQL</span> database user name. The <code class=\"filename\">pg_ident.conf</code> configuration file can be used to map principals to user names; for example, <code class=\"literal\">pgusername@realm</code> could be mapped to just <code class=\"literal\">pgusername</code>. Alternatively, you can use the full <code class=\"literal\">username@realm</code> principal as the role name in <span class=\"productname\">PostgreSQL</span> without any mapping.</p>\n<p><span class=\"productname\">PostgreSQL</span> also supports mapping client principals to user names by just stripping the realm from the principal. This method is supported for backwards compatibility and is strongly discouraged as it is then impossible to distinguish different users with the same user name but coming from different realms. To enable this, set <code class=\"literal\">include_realm</code> to 0. For simple single-realm installations, doing that combined with setting the <code class=\"literal\">krb_realm</code> parameter (which checks that the principal's realm matches exactly what is in the <code class=\"literal\">krb_realm</code> parameter) is still secure; but this is a less capable approach compared to specifying an explicit mapping in <code class=\"filename\">pg_ident.conf</code>.</p>\n<p>The location of the server's keytab file is specified by the <a class=\"xref\" href=\"/docs/18/runtime-config-connection.html#GUC-KRB-SERVER-KEYFILE\">krb_server_keyfile</a> configuration parameter. For security reasons, it is recommended to use a separate keytab just for the <span class=\"productname\">PostgreSQL</span> server rather than allowing the server to read the system keytab file. Make sure that your server keytab file is readable (and preferably only readable, not writable) by the <span class=\"productname\">PostgreSQL</span> server account. (See also <a class=\"xref\" href=\"/docs/18/postgres-user.html\" title=\"18.1.\u00a0The PostgreSQL User Account\">Section\u00a018.1</a>.)</p>\n<p>The keytab file is generated using the Kerberos software; see the Kerberos documentation for details. The following example shows doing this using the <span class=\"application\">kadmin</span> tool of MIT Kerberos:</p>\n<pre class=\"screen\"><code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>addprinc -randkey postgres/server.my.domain.org</code></strong>\n<code class=\"prompt\">kadmin% </code><strong class=\"userinput\"><code>ktadd -k krb5.keytab postgres/server.my.domain.org</code></strong>\n</pre>\n<p>The following authentication options are supported for the <span class=\"productname\">GSSAPI</span> authentication method:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">include_realm</code></span></dt>\n<dd>\n<p>If set to 0, the realm name from the authenticated user principal is stripped off before being passed through the user name mapping (<a class=\"xref\" href=\"/docs/18/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a>). This is discouraged and is primarily available for backwards compatibility, as it is not secure in multi-realm environments unless <code class=\"literal\">krb_realm</code> is also used. It is recommended to leave <code class=\"literal\">include_realm</code> set to the default (1) and to provide an explicit mapping in <code class=\"filename\">pg_ident.conf</code> to convert principal names to <span class=\"productname\">PostgreSQL</span> user names.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">map</code></span></dt>\n<dd>\n<p>Allows mapping from client principals to database user names. See <a class=\"xref\" href=\"/docs/18/auth-username-maps.html\" title=\"20.2.\u00a0User Name Maps\">Section\u00a020.2</a> for details. For a GSSAPI/Kerberos principal, such as <code class=\"literal\">username@EXAMPLE.COM</code> (or, less commonly, <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>), the user name used for mapping is <code class=\"literal\">username@EXAMPLE.COM</code> (or <code class=\"literal\">username/hostbased@EXAMPLE.COM</code>, respectively), unless <code class=\"literal\">include_realm</code> has been set to 0, in which case <code class=\"literal\">username</code> (or <code class=\"literal\">username/hostbased</code>) is what is seen as the system user name when mapping.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">krb_realm</code></span></dt>\n<dd>\n<p>Sets the realm to match user principal names against. If this parameter is set, only users of that realm will be accepted. If it is not set, users of any realm can connect, subject to whatever user name mapping is done.</p>\n</dd>\n</dl>\n</div>\n<p>In addition to these settings, which can be different for different <code class=\"filename\">pg_hba.conf</code> entries, there is the server-wide <a class=\"xref\" href=\"/docs/18/runtime-config-connection.html#GUC-KRB-CASEINS-USERS\">krb_caseins_users</a> configuration parameter. If that is set to true, client principals are matched to user map entries case-insensitively. <code class=\"literal\">krb_realm</code>, if set, is also matched case-insensitively.</p>\n</div>", "manual_path": "/docs/18/gssapi-auth.html", "comparison_data": {"method": "gss", "documented_option_names": ["include_realm", "krb_realm", "map"]}, "comparison_hash": "c58b84e18bba9d75d595bab34b326eb6a8580a80636f79642c4af8843e7123cf"}, "comparison": {"left": "17", "right": "18", "status": "unchanged", "diff": ""}}