gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
10KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>20.6. GSSAPI Authentication</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="auth-password.html" title="20.5. Password Authentication" /><link rel="next" href="sspi-auth.html" title="20.7. SSPI Authentication" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">20.6. GSSAPI Authentication</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="auth-password.html" title="20.5. Password Authentication">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="client-authentication.html" title="Chapter 20. Client Authentication">Up</a></td><th width="60%" align="center">Chapter 20. Client Authentication</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sspi-auth.html" title="20.7. SSPI Authentication">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="GSSAPI-AUTH"><div class="titlepage"><div><div><h2 class="title" style="clear: both">20.6. GSSAPI Authentication</h2></div></div></div><a id="id-1.6.7.13.2" class="indexterm"></a><p>
  3. <span class="productname">GSSAPI</span> is an industry-standard protocol
  4. for secure authentication defined in RFC 2743.
  5. <span class="productname">PostgreSQL</span>
  6. supports <span class="productname">GSSAPI</span> for use as either an encrypted,
  7. authenticated layer, or for authentication only.
  8. <span class="productname">GSSAPI</span> provides automatic authentication
  9. (single sign-on) for systems that support it. The authentication itself is
  10. secure. If <span class="productname">GSSAPI</span> encryption
  11. (see <code class="literal">hostgssenc</code>) or <acronym class="acronym">SSL</acronym> encryption are
  12. used, the data sent along the database connection will be encrypted;
  13. otherwise, it will not.
  14. </p><p>
  15. GSSAPI support has to be enabled when <span class="productname">PostgreSQL</span> is built;
  16. see <a class="xref" href="installation.html" title="Chapter 16. Installation from Source Code">Chapter 16</a> for more information.
  17. </p><p>
  18. When <span class="productname">GSSAPI</span> uses
  19. <span class="productname">Kerberos</span>, it uses a standard principal
  20. in the format
  21. <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>.
  22. The PostgreSQL server will accept any principal that is included in the keytab used by
  23. the server, but care needs to be taken to specify the correct principal details when
  24. making the connection from the client using the <code class="literal">krbsrvname</code> connection parameter. (See
  25. also <a class="xref" href="libpq-connect.html#LIBPQ-PARAMKEYWORDS" title="33.1.2. Parameter Key Words">Section 33.1.2</a>.) The installation default can be
  26. changed from the default <code class="literal">postgres</code> at build time using
  27. <code class="literal">./configure --with-krb-srvnam=</code><em class="replaceable"><code>whatever</code></em>.
  28. In most environments,
  29. this parameter never needs to be changed.
  30. Some Kerberos implementations might require a different service name,
  31. such as Microsoft Active Directory which requires the service name
  32. to be in upper case (<code class="literal">POSTGRES</code>).
  33. </p><p>
  34. <em class="replaceable"><code>hostname</code></em> is the fully qualified host name of the
  35. server machine. The service principal's realm is the preferred realm
  36. of the server machine.
  37. </p><p>
  38. Client principals can be mapped to different <span class="productname">PostgreSQL</span>
  39. database user names with <code class="filename">pg_ident.conf</code>. For example,
  40. <code class="literal">pgusername@realm</code> could be mapped to just <code class="literal">pgusername</code>.
  41. Alternatively, you can use the full <code class="literal">username@realm</code> principal as
  42. the role name in <span class="productname">PostgreSQL</span> without any mapping.
  43. </p><p>
  44. <span class="productname">PostgreSQL</span> also supports a parameter to strip the realm from
  45. the principal. This method is supported for backwards compatibility and is
  46. strongly discouraged as it is then impossible to distinguish different users
  47. with the same user name but coming from different realms. To enable this,
  48. set <code class="literal">include_realm</code> to 0. For simple single-realm
  49. installations, doing that combined with setting the
  50. <code class="literal">krb_realm</code> parameter (which checks that the principal's realm
  51. matches exactly what is in the <code class="literal">krb_realm</code> parameter)
  52. is still secure; but this is a
  53. less capable approach compared to specifying an explicit mapping in
  54. <code class="filename">pg_ident.conf</code>.
  55. </p><p>
  56. Make sure that your server keytab file is readable (and preferably
  57. only readable, not writable) by the <span class="productname">PostgreSQL</span>
  58. server account. (See also <a class="xref" href="postgres-user.html" title="18.1. The PostgreSQL User Account">Section 18.1</a>.) The location
  59. of the key file is specified by the <a class="xref" href="runtime-config-connection.html#GUC-KRB-SERVER-KEYFILE">krb_server_keyfile</a> configuration
  60. parameter. The default is
  61. <code class="filename">/usr/local/pgsql/etc/krb5.keytab</code> (or whatever
  62. directory was specified as <code class="varname">sysconfdir</code> at build time).
  63. For security reasons, it is recommended to use a separate keytab
  64. just for the <span class="productname">PostgreSQL</span> server rather
  65. than opening up permissions on the system keytab file.
  66. </p><p>
  67. The keytab file is generated by the Kerberos software; see the
  68. Kerberos documentation for details. The following example is
  69. for MIT-compatible Kerberos 5 implementations:
  70. </p><pre class="screen">
  71. <code class="prompt">kadmin% </code><strong class="userinput"><code>ank -randkey postgres/server.my.domain.org</code></strong>
  72. <code class="prompt">kadmin% </code><strong class="userinput"><code>ktadd -k krb5.keytab postgres/server.my.domain.org</code></strong>
  73. </pre><p>
  74. </p><p>
  75. When connecting to the database make sure you have a ticket for a
  76. principal matching the requested database user name. For example, for
  77. database user name <code class="literal">fred</code>, principal
  78. <code class="literal">fred@EXAMPLE.COM</code> would be able to connect. To also allow
  79. principal <code class="literal">fred/users.example.com@EXAMPLE.COM</code>, use a user name
  80. map, as described in <a class="xref" href="auth-username-maps.html" title="20.2. User Name Maps">Section 20.2</a>.
  81. </p><p>
  82. The following configuration options are supported for <span class="productname">GSSAPI</span>:
  83. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">include_realm</code></span></dt><dd><p>
  84. If set to 0, the realm name from the authenticated user principal is
  85. stripped off before being passed through the user name mapping
  86. (<a class="xref" href="auth-username-maps.html" title="20.2. User Name Maps">Section 20.2</a>). This is discouraged and is
  87. primarily available for backwards compatibility, as it is not secure
  88. in multi-realm environments unless <code class="literal">krb_realm</code> is
  89. also used. It is recommended to
  90. leave <code class="literal">include_realm</code> set to the default (1) and to
  91. provide an explicit mapping in <code class="filename">pg_ident.conf</code> to convert
  92. principal names to <span class="productname">PostgreSQL</span> user names.
  93. </p></dd><dt><span class="term"><code class="literal">map</code></span></dt><dd><p>
  94. Allows for mapping between system and database user names. See
  95. <a class="xref" href="auth-username-maps.html" title="20.2. User Name Maps">Section 20.2</a> for details. For a GSSAPI/Kerberos
  96. principal, such as <code class="literal">username@EXAMPLE.COM</code> (or, less
  97. commonly, <code class="literal">username/hostbased@EXAMPLE.COM</code>), the
  98. user name used for mapping is
  99. <code class="literal">username@EXAMPLE.COM</code> (or
  100. <code class="literal">username/hostbased@EXAMPLE.COM</code>, respectively),
  101. unless <code class="literal">include_realm</code> has been set to 0, in which case
  102. <code class="literal">username</code> (or <code class="literal">username/hostbased</code>)
  103. is what is seen as the system user name when mapping.
  104. </p></dd><dt><span class="term"><code class="literal">krb_realm</code></span></dt><dd><p>
  105. Sets the realm to match user principal names against. If this parameter
  106. is set, only users of that realm will be accepted. If it is not set,
  107. users of any realm can connect, subject to whatever user name mapping
  108. is done.
  109. </p></dd></dl></div><p>
  110. </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="auth-password.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="client-authentication.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sspi-auth.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">20.5. Password Authentication </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 20.7. SSPI Authentication</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1