~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-security

« back to all changes in this revision

Viewing changes to doc/src/sgml/client-auth.sgml

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-01 17:41:41 UTC
  • mfrom: (1.1.4 upstream)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20090701174141-jfmn9tt8e69m950x
Tags: 8.4.0-1
* Final 8.4.0 release. Major enhancements:
  - Windowing Functions
  - Common Table Expressions and Recursive Queries
  - Default and variadic parameters for functions
  - Parallel Restore
  - Column Permissions
  - Per-database locale settings
  - Improved hash indexes
  - Improved join performance for EXISTS and NOT EXISTS queries
  - Easier-to-use Warm Standby
  - Automatic sizing of the Free Space Map
  - Visibility Map (greatly reduces vacuum overhead for slowly-changing
    tables)
  - Version-aware psql (backslash commands work against older servers)
  - Support SSL certificates for user authentication
  - Per-function runtime statistics
  - Easy editing of functions in psql
  - New contrib modules: pg_stat_statements, auto_explain, citext,
    btree_gin 
  Upload to unstable, 8.4 is the new default. 
* debian/control: Build the versionless metapackages and have them point to
  8.4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!-- $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.121 2009/04/11 02:08:34 momjian Exp $ -->
 
1
<!-- $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.123 2009/06/24 13:46:32 mha Exp $ -->
2
2
 
3
3
<chapter id="client-authentication">
4
4
 <title>Client Authentication</title>
173
173
     <term><replaceable>database</replaceable></term>
174
174
     <listitem>
175
175
      <para>
176
 
       Specifies which database names this record matches.  The value
 
176
       Specifies which database name(s) this record matches.  The value
177
177
       <literal>all</literal> specifies that it matches all databases.
178
178
       The value <literal>sameuser</> specifies that the record
179
179
       matches if the requested database has the same name as the
194
194
     <term><replaceable>user</replaceable></term>
195
195
     <listitem>
196
196
      <para>
197
 
       Specifies which database user names this record
 
197
       Specifies which database user name(s) this record
198
198
       matches. The value <literal>all</literal> specifies that it
199
199
       matches all users.  Otherwise, this is either the name of a specific
200
200
       database user, or a group name preceded by <literal>+</>.
215
215
     <listitem>
216
216
      <para>
217
217
       Specifies the client machine IP address range that this record
218
 
       matches. It contains an IP address in standard dotted decimal
 
218
       matches. This field contains an IP address in standard dotted decimal
219
219
       notation and a CIDR mask length. (IP addresses can only be
220
220
       specified numerically, not as domain or host names.)  The mask
221
221
       length indicates the number of high-order bits of the client
269
269
       <literal>hostssl</literal>, and <literal>hostnossl</> records.
270
270
      </para>
271
271
     </listitem>
272
 
    </varlistentry>  
 
272
    </varlistentry>
273
273
 
274
274
    <varlistentry>
275
275
     <term><replaceable>auth-method</replaceable></term>
276
276
     <listitem>
277
277
      <para>
278
 
       Specifies the authentication method to use when connecting via
 
278
       Specifies the authentication method to use when a connection matches
279
279
       this record. The possible choices are summarized here; details
280
280
       are in <xref linkend="auth-methods">.
281
281
 
323
323
          authentication.
324
324
          Since the password is sent in clear text over the
325
325
          network, this should not be used on untrusted networks.
326
 
          It also does not usually work with threaded client applications.
327
326
          See <xref linkend="auth-password"> for details.
328
327
         </para>
329
328
        </listitem>
333
332
        <term><literal>gss</></term>
334
333
        <listitem>
335
334
         <para>
336
 
          Use GSSAPI to authenticate the user. This is only 
 
335
          Use GSSAPI to authenticate the user. This is only
337
336
          available for TCP/IP connections. See <xref
338
337
          linkend="gssapi-auth"> for details.
339
338
         </para>
369
368
          Obtain the operating system user name of the client (for
370
369
          TCP/IP connections by contacting the ident server on the
371
370
          client, for local connections by getting it from the
372
 
          operating system) and check if the user is allowed to
373
 
          connect as the requested database user by consulting the map
374
 
          specified after the <literal>ident</literal> key word.
 
371
          operating system) and check if it matches the requested
 
372
          database user name.
375
373
          See <xref linkend="auth-ident"> for details.
376
374
         </para>
377
375
        </listitem>
381
379
        <term><literal>ldap</></term>
382
380
        <listitem>
383
381
         <para>
384
 
          Authenticate using LDAP to a central server. See <xref
 
382
          Authenticate using an LDAP server. See <xref
385
383
          linkend="auth-ldap"> for details.
386
384
         </para>
387
385
        </listitem>
417
415
     <term><replaceable>auth-options</replaceable></term>
418
416
     <listitem>
419
417
      <para>
420
 
       This field contains zero or more name-value pairs with
421
 
       extra options passed to this authentication method. Details
422
 
       about which options are available for which authentication
423
 
       method appear below.
 
418
       After the <replaceable>auth-method</> field, there can be field(s) of
 
419
       the form <replaceable>name</><literal>=</><replaceable>value</> that
 
420
       specify options for the authentication method. Details about which
 
421
       options are available for which authentication method appear below.
424
422
      </para>
425
423
     </listitem>
426
424
    </varlistentry>
491
489
# The same using local loopback TCP/IP connections.
492
490
#
493
491
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
494
 
host    all         all         127.0.0.1/32          trust     
 
492
host    all         all         127.0.0.1/32          trust
495
493
 
496
 
# The same as the last line but using a separate netmask column
 
494
# The same as the previous line, but using a separate netmask column
497
495
#
498
496
# TYPE  DATABASE    USER        IP-ADDRESS    IP-MASK             METHOD
499
 
host    all         all         127.0.0.1     255.255.255.255     trust     
 
497
host    all         all         127.0.0.1     255.255.255.255     trust
500
498
 
501
499
# Allow any user from any host with IP address 192.168.93.x to connect
502
500
# to database "postgres" as the same user name that ident reports for
503
501
# the connection (typically the Unix user name).
504
 
 
502
#
505
503
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
506
504
host    postgres    all         192.168.93.0/24       ident
507
505
 
508
 
# Allow a user from host 192.168.12.10 to connect to database
 
506
# Allow any user from host 192.168.12.10 to connect to database
509
507
# "postgres" if the user's password is correctly supplied.
510
 
 
508
#
511
509
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
512
510
host    postgres    all         192.168.12.10/32      md5
513
511
 
514
512
# In the absence of preceding "host" lines, these two lines will
515
 
# reject all connection from 192.168.54.1 (since that entry will be
 
513
# reject all connections from 192.168.54.1 (since that entry will be
516
514
# matched first), but allow Kerberos 5 connections from anywhere else
517
515
# on the Internet.  The zero mask means that no bits of the host IP
518
516
# address are considered so it matches any host.
519
 
 
517
#
520
518
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
521
519
host    all         all         192.168.54.1/32       reject
522
520
host    all         all         0.0.0.0/0             krb5
560
558
 
561
559
  <para>
562
560
   When using an external authentication system like Ident or GSSAPI,
563
 
   the name of the operating system user that initiated the connection may
564
 
   not be the same as the database user he is requesting to connect as.
 
561
   the name of the operating system user that initiated the connection
 
562
   might not be the same as the database user he needs to connect as.
565
563
   In this case, a user name map can be applied to map the operating system
566
 
   username to a database user, using the <filename>pg_ident.conf</filename>
567
 
   file. In order to use username mapping, specify
 
564
   username to a database user.  To use username mapping, specify
568
565
   <literal>map</literal>=<replaceable>map-name</replaceable>
569
566
   in the options field in <filename>pg_hba.conf</filename>. This option is
570
567
   supported for all authentication methods that receive external usernames.
571
 
   Since the <filename>pg_ident.conf</filename> file can contain multiple maps,
 
568
   Since different mappings might be needed for different connections,
572
569
   the name of the map to be used is specified in the
573
570
   <replaceable>map-name</replaceable> parameter in <filename>pg_hba.conf</filename>
574
571
   to indicate which map to use for each individual connection.
575
572
  </para>
576
573
 
577
574
  <para>
578
 
   Ident maps are defined in the ident map file, which by default is named
 
575
   Username maps are defined in the ident map file, which by default is named
579
576
   <filename>pg_ident.conf</><indexterm><primary>pg_ident.conf</primary></indexterm>
580
577
   and is stored in the
581
578
   cluster's data directory.  (It is possible to place the map file
589
586
   <filename>pg_hba.conf</>.  The
590
587
   <replaceable>map-name</> is an arbitrary name that will be used to
591
588
   refer to this mapping in <filename>pg_hba.conf</filename>. The other
592
 
   two fields specify which operating system user is allowed to connect
593
 
   as which database user. The same <replaceable>map-name</> can be
594
 
   used repeatedly to specify more user-mappings within a single map.
 
589
   two fields specify an operating system user name and a matching
 
590
   database user name. The same <replaceable>map-name</> can be
 
591
   used repeatedly to specify multiple user-mappings within a single map.
 
592
  </para>
 
593
  <para>
595
594
   There is no restriction regarding how many database users a given
596
 
   operating system user can correspond to, nor vice versa.
 
595
   operating system user can correspond to, nor vice versa.  Thus, entries
 
596
   in a map should be thought of as meaning <quote>this operating system
 
597
   user is allowed to connect as this database user</quote>, rather than
 
598
   implying that they are equivalent.  The connection will be allowed if
 
599
   there is any map entry that matches the user name obtained from the
 
600
   external authentication system to the database user name that the
 
601
   user has requested to connect as.
597
602
  </para>
598
603
  <para>
599
604
   If the <replaceable>system-username</> field starts with a slash (<literal>/</>),
600
 
   the contents of the field is treated as a regular expression. This regular
601
 
   expression supports a single capture, which can be back-referenced as
602
 
   <literal>\1</> (backslash-one). This allows the mapping of different syntax
603
 
   names with a single line.
604
 
   <programlisting>
605
 
mymap   /(.*)@mydomain.com   \1
606
 
mymap   /(.*)@otherdomain.com guest
607
 
   </programlisting>
608
 
   will "remove" the domain part for users with system usernames @mydomain.com, and
609
 
   allow all users from @otherdomain.com to log in as guest.
 
605
   the remainder of the field is treated as a regular expression.
 
606
   (See <xref linkend="posix-syntax-details"> for details of
 
607
   <productname>PostgreSQL</>'s regular expression syntax.
 
608
   Regular expressions in username maps are always treated as being
 
609
   <quote>advanced</> flavor.)  The regular
 
610
   expression can include a single capture, or parenthesized subexpression,
 
611
   which can then be referenced in the <replaceable>database-username</>
 
612
   field as <literal>\1</> (backslash-one).  This allows the mapping of
 
613
   multiple usernames in a single line, which is particularly useful for
 
614
   simple syntax substitutions.  For example, these entries
 
615
<programlisting>
 
616
mymap   /^(.*)@mydomain\.com$      \1
 
617
mymap   /^(.*)@otherdomain\.com$   guest
 
618
</programlisting>
 
619
   will remove the domain part for users with system usernames that end with
 
620
   <literal>@mydomain.com</>, and allow any user whose system name ends with
 
621
   <literal>@otherdomain.com</> to log in as <literal>guest</>.
610
622
  </para>
611
623
 
 
624
  <tip>
 
625
   <para>
 
626
    Keep in mind that by default, a regular expression can match just part of
 
627
    a string.  It's usually wise to use <literal>^</> and <literal>$</>, as
 
628
    shown in the above example, to force the match to be to the entire
 
629
    system username.
 
630
   </para>
 
631
  </tip>
 
632
 
612
633
  <para>
613
634
   The <filename>pg_ident.conf</filename> file is read on start-up and
614
635
   when the main server process receives a
638
659
  <example id="example-pg-ident.conf">
639
660
   <title>An example <filename>pg_ident.conf</> file</title>
640
661
<programlisting>
641
 
# MAPNAME     IDENT-USERNAME    PG-USERNAME
 
662
# MAPNAME     SYSTEM-USERNAME   PG-USERNAME
642
663
 
643
664
omicron       bryanh            bryanh
644
665
omicron       ann               ann
663
684
    When <literal>trust</> authentication is specified,
664
685
    <productname>PostgreSQL</productname> assumes that anyone who can
665
686
    connect to the server is authorized to access the database with
666
 
    whatever database user name they specify (including superusers).
 
687
    whatever database user name they specify (even superuser names).
667
688
    Of course, restrictions made in the <literal>database</> and
668
689
    <literal>user</> columns still apply.
669
690
    This method should only be used when there is adequate
687
708
 
688
709
   <para>
689
710
    Setting file-system permissions only helps for Unix-socket connections.
690
 
    Local TCP/IP connections are not restricted by it; therefore, if you want
691
 
    to use file-system permissions for local security, remove the <literal>host ...
692
 
    127.0.0.1 ...</> line from <filename>pg_hba.conf</>, or change it to a
 
711
    Local TCP/IP connections are not restricted by file-system permissions.
 
712
    Therefore, if you want to use file-system permissions for local security,
 
713
    remove the <literal>host ... 127.0.0.1 ...</> line from
 
714
    <filename>pg_hba.conf</>, or change it to a
693
715
    non-<literal>trust</> authentication method.
694
716
   </para>
695
717
 
715
737
   </indexterm>
716
738
 
717
739
   <para>
718
 
    The password-based authentication methods are <literal>md5</>,
 
740
    The password-based authentication methods are <literal>md5</>
719
741
    and <literal>password</>. These methods operate
720
742
    similarly except for the way that the password is sent across the
721
743
    connection: respectively, MD5-hashed and clear-text.
725
747
    If you are at all concerned about password
726
748
    <quote>sniffing</> attacks then <literal>md5</> is preferred.
727
749
    Plain <literal>password</> should always be avoided if possible.
728
 
    <literal>md5</> cannot be used with <xref
729
 
    linkend="guc-db-user-namespace">.
 
750
    However, <literal>md5</> cannot be used with the <xref
 
751
    linkend="guc-db-user-namespace"> feature.  If the connection is
 
752
    protected by SSL encryption then <literal>password</> can be used
 
753
    safely (though SSL certificate authentication might be a better
 
754
    choice if one is depending on using SSL).
730
755
   </para>
731
756
 
732
757
   <para>
752
777
 
753
778
   <para>
754
779
    <productname>GSSAPI</productname> is an industry-standard protocol
755
 
    for secure authentication defined in RFC 2743. 
 
780
    for secure authentication defined in RFC 2743.
756
781
    <productname>PostgreSQL</productname> supports
757
782
    <productname>GSSAPI</productname> with <productname>Kerberos</productname>
758
783
    authentication according to RFC 1964. <productname>GSSAPI</productname>
759
784
    provides automatic authentication (single sign-on) for systems
760
785
    that support it. The authentication itself is secure, but the
761
 
    data sent over the connection will be in clear unless
 
786
    data sent over the database connection will be in clear unless
762
787
    <acronym>SSL</acronym> is used.
763
788
   </para>
764
789
 
765
790
   <para>
766
791
    When <productname>GSSAPI</productname> uses
767
792
    <productname>Kerberos</productname>, it uses a standard principal
768
 
    in format
 
793
    in the format
769
794
    <literal><replaceable>servicename</>/<replaceable>hostname</>@<replaceable>realm</></literal>. For information about the parts of the principal, and
770
795
    how to set up the required keys, see <xref linkend="kerberos-auth">.
771
796
    GSSAPI support has to be enabled when <productname>PostgreSQL</> is built;
776
801
    The following configuration options are supported for <productname>GSSAPI</productname>:
777
802
    <variablelist>
778
803
     <varlistentry>
779
 
      <term>map</term>
 
804
      <term><literal>map</literal></term>
780
805
      <listitem>
781
806
       <para>
782
807
        Allows for mapping between system and database usernames. See
786
811
     </varlistentry>
787
812
 
788
813
     <varlistentry>
789
 
      <term>include_realm</term>
 
814
      <term><literal>include_realm</literal></term>
790
815
      <listitem>
791
816
       <para>
792
 
        Include the realm name from the authenticated user principal. This is useful
793
 
        in combination with Username maps (See <xref linkend="auth-username-maps">
794
 
        for details), especially with regular expressions, to map users from
795
 
        multiple realms.
 
817
        If set to <literal>1</>, the realm name from the authenticated user
 
818
        principal is included in the system user name that's passed through
 
819
        username mapping (<xref linkend="auth-username-maps">). This is
 
820
        useful for handling users from multiple realms.
796
821
       </para>
797
822
      </listitem>
798
823
     </varlistentry>
799
824
 
800
825
     <varlistentry>
801
 
      <term>krb_realm</term>
 
826
      <term><literal>krb_realm</literal></term>
802
827
      <listitem>
803
828
       <para>
804
829
        Sets the realm to match user principal names against. If this parameter
805
 
        is not set, the realm of the user will be ignored.
 
830
        is set, only users of that realm will be accepted.  If it is not set,
 
831
        users of any realm can connect, subject to whatever username mapping
 
832
        is done.
806
833
       </para>
807
834
      </listitem>
808
835
     </varlistentry>
819
846
 
820
847
   <para>
821
848
    <productname>SSPI</productname> is a <productname>Windows</productname>
822
 
    technology for secure authentication with single sign-on. 
 
849
    technology for secure authentication with single sign-on.
823
850
    <productname>PostgreSQL</productname> will use SSPI in
824
851
    <literal>negotiate</literal> mode, which will use
825
852
    <productname>Kerberos</productname> when possible and automatically
829
856
   </para>
830
857
 
831
858
   <para>
832
 
    When using <productname>Kerberos</productname> authentication, 
833
 
    <productname>SSPI</productname> works the same way 
 
859
    When using <productname>Kerberos</productname> authentication,
 
860
    <productname>SSPI</productname> works the same way
834
861
    <productname>GSSAPI</productname> does. See <xref linkend="gssapi-auth">
835
862
    for details.
836
863
   </para>
839
866
    The following configuration options are supported for <productname>SSPI</productname>:
840
867
    <variablelist>
841
868
     <varlistentry>
842
 
      <term>map</term>
 
869
      <term><literal>map</literal></term>
843
870
      <listitem>
844
871
       <para>
845
872
        Allows for mapping between system and database usernames. See
849
876
     </varlistentry>
850
877
 
851
878
     <varlistentry>
852
 
      <term>include_realm</term>
 
879
      <term><literal>include_realm</literal></term>
853
880
      <listitem>
854
881
       <para>
855
 
        Include the realm name from the authenticated user principal. This is useful
856
 
        in combination with Username maps (See <xref linkend="auth-username-maps">
857
 
        for details), especially with regular expressions, to map users from
858
 
        multiple realms.
 
882
        If set to <literal>1</>, the realm name from the authenticated user
 
883
        principal is included in the system user name that's passed through
 
884
        username mapping (<xref linkend="auth-username-maps">). This is
 
885
        useful for handling users from multiple realms.
859
886
       </para>
860
887
      </listitem>
861
888
     </varlistentry>
862
889
 
863
890
     <varlistentry>
864
 
      <term>krb_realm</term>
 
891
      <term><literal>krb_realm</literal></term>
865
892
      <listitem>
866
893
       <para>
867
894
        Sets the realm to match user principal names against. If this parameter
868
 
        is not set, the realm of the user will be ignored.
 
895
        is set, only users of that realm will be accepted.  If it is not set,
 
896
        users of any realm can connect, subject to whatever username mapping
 
897
        is done.
869
898
       </para>
870
899
      </listitem>
871
900
     </varlistentry>
894
923
    authentication system suitable for distributed computing over a public
895
924
    network. A description of the <productname>Kerberos</productname> system
896
925
    is far beyond the scope of this document; in full generality it can be
897
 
    quite complex (yet powerful). The 
 
926
    quite complex (yet powerful). The
898
927
    <ulink url="http://www.nrl.navy.mil/CCS/people/kenh/kerberos-faq.html">
899
 
    Kerberos <acronym>FAQ</></ulink> or 
 
928
    Kerberos <acronym>FAQ</></ulink> or
900
929
    <ulink url="http://web.mit.edu/kerberos/www/">MIT Kerberos page</ulink>
901
930
    can be good starting points for exploration.
902
931
    Several sources for <productname>Kerberos</> distributions exist.
923
952
    client side using the <literal>krbsrvname</> connection parameter. (See
924
953
    also <xref linkend="libpq-connect">.)  The installation default can be
925
954
    changed from the default <literal>postgres</literal> at build time using
926
 
    <literal>./configure --with-krb-srvnam=whatever</>. In most environments,
 
955
    <literal>./configure --with-krb-srvnam=</><replaceable>whatever</>.
 
956
    In most environments,
927
957
    this parameter never needs to be changed. However, to support multiple
928
958
    <productname>PostgreSQL</> installations on the same host it is necessary.
929
959
    Some Kerberos implementations might also require a different service name,
940
970
   <para>
941
971
    Client principals must have their <productname>PostgreSQL</> database user
942
972
    name as their first component, for example
943
 
    <literal>pgusername@realm</>. By default, the realm of the client is
 
973
    <literal>pgusername@realm</>.  Alternatively, you can use a username
 
974
    mapping to map from the first component of the principal name to the
 
975
    database user name.  By default, the realm of the client is
944
976
    not checked by <productname>PostgreSQL</>. If you have cross-realm
945
977
    authentication enabled and need to verify the realm, use the
946
 
    krb_realm parameter in <filename>pg_hba.conf</>.
 
978
    <literal>krb_realm</> parameter, or enable <literal>include_realm</>
 
979
    and use username mapping to check the realm.
947
980
   </para>
948
981
 
949
982
   <para>
958
991
   </para>
959
992
 
960
993
   <para>
961
 
    The keytab file is generated by the Kerberos software; see the 
962
 
    Kerberos documentation for details. The following example is 
 
994
    The keytab file is generated by the Kerberos software; see the
 
995
    Kerberos documentation for details. The following example is
963
996
   for MIT-compatible Kerberos 5 implementations:
964
997
<screen>
965
998
<prompt>kadmin% </><userinput>ank -randkey postgres/server.my.domain.org</>
987
1020
   </para>
988
1021
 
989
1022
   <para>
990
 
    The following configuration options are supported for <productname>Kerberos</productname>:
 
1023
    The following configuration options are supported for
 
1024
    <productname>Kerberos</productname>:
991
1025
    <variablelist>
992
1026
     <varlistentry>
993
 
      <term>map</term>
 
1027
      <term><literal>map</literal></term>
994
1028
      <listitem>
995
1029
       <para>
996
1030
        Allows for mapping between system and database usernames. See
1000
1034
     </varlistentry>
1001
1035
 
1002
1036
     <varlistentry>
1003
 
      <term>include_realm</term>
 
1037
      <term><literal>include_realm</literal></term>
1004
1038
      <listitem>
1005
1039
       <para>
1006
 
        Include the realm name from the authenticated user principal. This is useful
1007
 
        in combination with Username maps (See <xref linkend="auth-username-maps">
1008
 
        for details), especially with regular expressions, to map users from
1009
 
        multiple realms.
 
1040
        If set to <literal>1</>, the realm name from the authenticated user
 
1041
        principal is included in the system user name that's passed through
 
1042
        username mapping (<xref linkend="auth-username-maps">). This is
 
1043
        useful for handling users from multiple realms.
1010
1044
       </para>
1011
1045
      </listitem>
1012
1046
     </varlistentry>
1013
1047
 
1014
1048
     <varlistentry>
1015
 
      <term>krb_realm</term>
 
1049
      <term><literal>krb_realm</literal></term>
1016
1050
      <listitem>
1017
1051
       <para>
1018
1052
        Sets the realm to match user principal names against. If this parameter
1019
 
        is not set, the realm of the user will be ignored.
 
1053
        is set, only users of that realm will be accepted.  If it is not set,
 
1054
        users of any realm can connect, subject to whatever username mapping
 
1055
        is done.
1020
1056
       </para>
1021
1057
      </listitem>
1022
1058
     </varlistentry>
1023
1059
 
1024
1060
     <varlistentry>
1025
 
      <term>krb_server_hostname</term>
 
1061
      <term><literal>krb_server_hostname</literal></term>
1026
1062
      <listitem>
1027
1063
       <para>
1028
1064
        Sets the host name part of the service principal.
1046
1082
 
1047
1083
   <para>
1048
1084
    The ident authentication method works by obtaining the client's
1049
 
    operating system user name, then optionally determining the allowed 
1050
 
    database user names using a map file that lists the permitted
1051
 
    corresponding pairs of names.  The determination of the client's
 
1085
    operating system user name and using it as the allowed database user
 
1086
    name (with an optional username mapping).
 
1087
    The determination of the client's
1052
1088
    user name is the security-critical point, and it works differently
1053
1089
    depending on the connection type.
1054
1090
   </para>
1057
1093
    The following configuration options are supported for <productname>ident</productname>:
1058
1094
    <variablelist>
1059
1095
     <varlistentry>
1060
 
      <term>map</term>
 
1096
      <term><literal>map</literal></term>
1061
1097
      <listitem>
1062
1098
       <para>
1063
1099
        Allows for mapping between system and database usernames. See
1122
1158
    On systems supporting <symbol>SO_PEERCRED</symbol> requests for
1123
1159
    Unix-domain sockets (currently <systemitem
1124
1160
    class="osname">Linux</>, <systemitem class="osname">FreeBSD</>,
1125
 
    <systemitem class="osname">NetBSD</>, <systemitem class="osname">OpenBSD</>, 
1126
 
    <systemitem class="osname">BSD/OS</>, and <systemitem class="osname">Solaris</systemitem>), ident authentication can also 
 
1161
    <systemitem class="osname">NetBSD</>, <systemitem class="osname">OpenBSD</>,
 
1162
    <systemitem class="osname">BSD/OS</>, and <systemitem class="osname">Solaris</systemitem>), ident authentication can also
1127
1163
    be applied to local connections. In this case, no security risk is added by
1128
1164
    using ident authentication; indeed it is a preferable choice for
1129
1165
    local connections on such systems.
1161
1197
   <para>
1162
1198
    The server will bind to the distinguished name constructed as
1163
1199
    <replaceable>prefix</> <replaceable>username</> <replaceable>suffix</>.
1164
 
    before the bind. Typically, the prefix parameter is used to specify
1165
 
    <replaceable>cn=</>, or <replaceable>DOMAIN\</> in an Active
1166
 
    Directory environment, and suffix is used to specify the remaining part
1167
 
    of the DN in a non-Active Directory environment.
 
1200
    Typically, the <replaceable>prefix</> parameter is used to specify
 
1201
    <literal>cn=</>, or <replaceable>DOMAIN</><literal>\</> in an Active
 
1202
    Directory environment.  <replaceable>suffix</> is used to specify the
 
1203
    remaining part of the DN in a non-Active Directory environment.
1168
1204
   </para>
1169
1205
 
1170
1206
   <para>
1171
1207
    The following configuration options are supported for LDAP:
1172
1208
    <variablelist>
1173
1209
     <varlistentry>
1174
 
      <term>ldapserver</term>
 
1210
      <term><literal>ldapserver</literal></term>
1175
1211
      <listitem>
1176
1212
       <para>
1177
1213
        Name or IP of LDAP server to connect to.
1179
1215
      </listitem>
1180
1216
     </varlistentry>
1181
1217
     <varlistentry>
1182
 
      <term>ldapprefix</term>
1183
 
      <listitem>
1184
 
       <para>
1185
 
        String to prepend to the username when building the base DN to
1186
 
        bind as.
1187
 
       </para>
1188
 
      </listitem>
1189
 
     </varlistentry>
1190
 
     <varlistentry>
1191
 
      <term>ldapsuffix</term>
1192
 
      <listitem>
1193
 
       <para>
1194
 
        String to append to the username when building the base DN to
1195
 
        bind as.
1196
 
       </para>
1197
 
      </listitem>
1198
 
     </varlistentry>
1199
 
     <varlistentry>
1200
 
      <term>ldapport</term>
 
1218
      <term><literal>ldapprefix</literal></term>
 
1219
      <listitem>
 
1220
       <para>
 
1221
        String to prepend to the username when forming the DN to bind as.
 
1222
       </para>
 
1223
      </listitem>
 
1224
     </varlistentry>
 
1225
     <varlistentry>
 
1226
      <term><literal>ldapsuffix</literal></term>
 
1227
      <listitem>
 
1228
       <para>
 
1229
        String to append to the username when forming the DN to bind as.
 
1230
       </para>
 
1231
      </listitem>
 
1232
     </varlistentry>
 
1233
     <varlistentry>
 
1234
      <term><literal>ldapport</literal></term>
1201
1235
      <listitem>
1202
1236
       <para>
1203
1237
        Port number on LDAP server to connect to. If no port is specified,
1206
1240
      </listitem>
1207
1241
     </varlistentry>
1208
1242
     <varlistentry>
1209
 
      <term>ldaptls</term>
 
1243
      <term><literal>ldaptls</literal></term>
1210
1244
      <listitem>
1211
1245
       <para>
1212
 
        Set to 1 to make the connection between PostgreSQL and the
 
1246
        Set to <literal>1</> to make the connection between PostgreSQL and the
1213
1247
        LDAP server use TLS encryption. Note that this only encrypts
1214
 
        the traffic to the LDAP server - the connection to the client
1215
 
        may still be unencrypted unless TLS is used there as well.
 
1248
        the traffic to the LDAP server &mdash; the connection to the client
 
1249
        will still be unencrypted unless SSL is used.
1216
1250
       </para>
1217
1251
      </listitem>
1218
1252
     </varlistentry>
1222
1256
   <note>
1223
1257
    <para>
1224
1258
     Since LDAP often uses commas and spaces to separate the different
1225
 
     parts of a DN, it is advised to always use double-quoted parameter
1226
 
     values when configuring LDAP options, such as:
 
1259
     parts of a DN, it is often necessary to use double-quoted parameter
 
1260
     values when configuring LDAP options, for example:
1227
1261
    </para>
1228
1262
   </note>
1229
1263
    <synopsis>
1230
 
ldapserver=ldap.example.net prefix="cn=" suffix="dc=example, dc=net"
 
1264
ldapserver=ldap.example.net ldapprefix="cn=" ldapsuffix=", dc=example, dc=net"
1231
1265
    </synopsis>
1232
1266
 
1233
1267
  </sect2>
1243
1277
    This authentication method uses SSL client certificates to perform
1244
1278
    authentication. It is therefore only available for SSL connections.
1245
1279
    When using this authentication method, the server will require that
1246
 
    the client provide a certificate. No password prompt will be sent
 
1280
    the client provide a valid certificate. No password prompt will be sent
1247
1281
    to the client. The <literal>cn</literal> attribute of the certificate
1248
 
    will be compared to the login username, and if they match the
1249
 
    login will be allowed. Username mapping can be used if the usernames
1250
 
    don't match.
 
1282
    will be compared to the requested database username, and if they match
 
1283
    the login will be allowed.  Username mapping can be used to allow
 
1284
    <literal>cn</literal> to be different from the database username.
 
1285
   </para>
 
1286
 
 
1287
   <para>
 
1288
    The following configuration options are supported for SSL certificate
 
1289
    authentication:
 
1290
    <variablelist>
 
1291
     <varlistentry>
 
1292
      <term><literal>map</literal></term>
 
1293
      <listitem>
 
1294
       <para>
 
1295
        Allows for mapping between system and database usernames. See
 
1296
        <xref linkend="auth-username-maps"> for details.
 
1297
       </para>
 
1298
      </listitem>
 
1299
     </varlistentry>
 
1300
    </variablelist>
1251
1301
   </para>
1252
1302
  </sect2>
1253
1303
 
1265
1315
    default PAM service name is <literal>postgresql</literal>.
1266
1316
    PAM is used only to validate user name/password pairs.
1267
1317
    Therefore the user must already exist in the database before PAM
1268
 
    can be used for authentication.  For more information about 
 
1318
    can be used for authentication.  For more information about
1269
1319
    PAM, please read the <ulink url="http://www.kernel.org/pub/linux/libs/pam/">
1270
1320
    <productname>Linux-PAM</> Page</ulink>
1271
1321
    and the <ulink url="http://www.sun.com/software/solaris/pam/">
1276
1326
    The following configuration options are supported for PAM:
1277
1327
    <variablelist>
1278
1328
     <varlistentry>
1279
 
      <term>pamservice</term>
 
1329
      <term><literal>pamservice</literal></term>
1280
1330
      <listitem>
1281
1331
       <para>
1282
1332
        PAM service name.
1290
1340
    <para>
1291
1341
     If PAM is set up to read <filename>/etc/shadow</>, authentication
1292
1342
     will fail because the PostgreSQL server is started by a non-root
1293
 
     user.  However, this is not an issue with LDAP or other authentication
1294
 
     methods.
 
1343
     user.  However, this is not an issue when PAM is configured to use
 
1344
     LDAP or other authentication methods.
1295
1345
    </para>
1296
1346
   </note>
1297
1347
  </sect2>
1301
1351
   <title>Authentication problems</title>
1302
1352
 
1303
1353
   <para>
1304
 
    Genuine authentication failures and related problems generally
1305
 
    manifest themselves through error messages like the following.
 
1354
    Authentication failures and related problems generally
 
1355
    manifest themselves through error messages like the following:
1306
1356
   </para>
1307
1357
 
1308
1358
   <para>
1332
1382
<programlisting>
1333
1383
FATAL:  user "andym" does not exist
1334
1384
</programlisting>
1335
 
    The indicated user name was not found.
 
1385
    The indicated database user name was not found.
1336
1386
   </para>
1337
1387
 
1338
1388
   <para>