Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 840b7f5

Browse files
committed
Update administrator's guide chapters for ROLEs patch.
1 parent bf86bac commit 840b7f5

File tree

4 files changed

+339
-172
lines changed

4 files changed

+339
-172
lines changed

doc/src/sgml/client-auth.sgml

+82-61
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.82 2005/06/27 02:04:23 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.83 2005/08/14 23:35:37 tgl Exp $
33
-->
44

55
<chapter id="client-authentication">
@@ -11,20 +11,30 @@ $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.82 2005/06/27 02:04:23 neil
1111

1212
<para>
1313
When a client application connects to the database server, it
14-
specifies which <productname>PostgreSQL</productname> user name it
14+
specifies which <productname>PostgreSQL</productname> database user name it
1515
wants to connect as, much the same way one logs into a Unix computer
1616
as a particular user. Within the SQL environment the active database
1717
user name determines access privileges to database objects &mdash; see
1818
<xref linkend="user-manag"> for more information. Therefore, it is
1919
essential to restrict which database users can connect.
2020
</para>
2121

22+
<note>
23+
<para>
24+
As explained in <xref linkend="user-manag">,
25+
<productname>PostgreSQL</productname> actually does privilege
26+
management in terms of <quote>roles</>. In this chapter, we
27+
consistently use <firstterm>database user</> to mean <quote>role with the
28+
<literal>LOGIN</> privilege</quote>.
29+
</para>
30+
</note>
31+
2232
<para>
2333
<firstterm>Authentication</firstterm> is the process by which the
2434
database server establishes the identity of the client, and by
2535
extension determines whether the client application (or the user
2636
who runs the client application) is permitted to connect with the
27-
user name that was requested.
37+
database user name that was requested.
2838
</para>
2939

3040
<para>
@@ -35,7 +45,7 @@ $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.82 2005/06/27 02:04:23 neil
3545
</para>
3646

3747
<para>
38-
<productname>PostgreSQL</productname> user names are logically
48+
<productname>PostgreSQL</productname> database user names are logically
3949
separate from user names of the operating system in which the server
4050
runs. If all the users of a particular server also have accounts on
4151
the server's machine, it makes sense to assign database user names
@@ -88,13 +98,13 @@ $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.82 2005/06/27 02:04:23 neil
8898
<para>
8999
A record may have one of the seven formats
90100
<synopsis>
91-
local <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>authentication-method</replaceable> <optional><replaceable>authentication-option</replaceable></optional>
92-
host <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>CIDR-address</replaceable> <replaceable>authentication-method</replaceable> <optional><replaceable>authentication-option</replaceable></optional>
93-
hostssl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>CIDR-address</replaceable> <replaceable>authentication-method</replaceable> <optional><replaceable>authentication-option</replaceable></optional>
94-
hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>CIDR-address</replaceable> <replaceable>authentication-method</replaceable> <optional><replaceable>authentication-option</replaceable></optional>
95-
host <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>authentication-method</replaceable> <optional><replaceable>authentication-option</replaceable></optional>
96-
hostssl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>authentication-method</replaceable> <optional><replaceable>authentication-option</replaceable></optional>
97-
hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>authentication-method</replaceable> <optional><replaceable>authentication-option</replaceable></optional>
101+
local <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-option</replaceable></optional>
102+
host <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>CIDR-address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-option</replaceable></optional>
103+
hostssl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>CIDR-address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-option</replaceable></optional>
104+
hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>CIDR-address</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-option</replaceable></optional>
105+
host <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-option</replaceable></optional>
106+
hostssl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-option</replaceable></optional>
107+
hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable> <replaceable>IP-address</replaceable> <replaceable>IP-mask</replaceable> <replaceable>auth-method</replaceable> <optional><replaceable>auth-option</replaceable></optional>
98108
</synopsis>
99109
The meaning of the fields is as follows:
100110

@@ -165,16 +175,18 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
165175
<term><replaceable>database</replaceable></term>
166176
<listitem>
167177
<para>
168-
Specifies which databases this record matches. The value
178+
Specifies which database names this record matches. The value
169179
<literal>all</literal> specifies that it matches all databases.
170180
The value <literal>sameuser</> specifies that the record
171181
matches if the requested database has the same name as the
172-
requested user. The value <literal>samegroup</> specifies that
173-
the requested user must be a member of the group with the same
174-
name as the requested database. Otherwise, this is the name of
182+
requested user. The value <literal>samerole</> specifies that
183+
the requested user must be a member of the role with the same
184+
name as the requested database. (<literal>samegroup</> is an
185+
obsolete but still accepted spelling of <literal>samerole</>.)
186+
Otherwise, this is the name of
175187
a specific <productname>PostgreSQL</productname> database.
176188
Multiple database names can be supplied by separating them with
177-
commas. A file containing database names can be specified by
189+
commas. A separate file containing database names can be specified by
178190
preceding the file name with <literal>@</>.
179191
</para>
180192
</listitem>
@@ -184,13 +196,17 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
184196
<term><replaceable>user</replaceable></term>
185197
<listitem>
186198
<para>
187-
Specifies which <productname>PostgreSQL</> users this record
199+
Specifies which database user names this record
188200
matches. The value <literal>all</literal> specifies that it
189-
matches all users. Otherwise, this is the name of a specific
190-
<productname>PostgreSQL</productname> user. Multiple user names
191-
can be supplied by separating them with commas. Group names can
192-
be specified by preceding the group name with <literal>+</>. A
193-
file containing user names can be specified by preceding the
201+
matches all users. Otherwise, this is either the name of a specific
202+
database user, or a group name preceded by <literal>+</>.
203+
(Recall that there is no real distinction between users and groups
204+
in <productname>PostgreSQL</>; a <literal>+</> mark really means
205+
<quote>match any of the roles that are directly or indirectly members
206+
of this role</>, while a name without a <literal>+</> mark matches
207+
only that specific role.)
208+
Multiple user names can be supplied by separating them with commas.
209+
A separate file containing user names can be specified by preceding the
194210
file name with <literal>@</>.
195211
</para>
196212
</listitem>
@@ -257,7 +273,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
257273
</varlistentry>
258274

259275
<varlistentry>
260-
<term><replaceable>authentication-method</replaceable></term>
276+
<term><replaceable>auth-method</replaceable></term>
261277
<listitem>
262278
<para>
263279
Specifies the authentication method to use when connecting via
@@ -369,7 +385,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
369385
</varlistentry>
370386

371387
<varlistentry>
372-
<term><replaceable>authentication-option</replaceable></term>
388+
<term><replaceable>auth-option</replaceable></term>
373389
<listitem>
374390
<para>
375391
The meaning of this optional field depends on the chosen
@@ -424,7 +440,7 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
424440
<title>Example <filename>pg_hba.conf</filename> entries</title>
425441
<programlisting>
426442
# Allow any user on the local system to connect to any database under
427-
# any user name using Unix-domain sockets (the default for local
443+
# any database user name using Unix-domain sockets (the default for local
428444
# connections).
429445
#
430446
# TYPE DATABASE USER CIDR-ADDRESS METHOD
@@ -445,7 +461,7 @@ host all all 127.0.0.1 255.255.255.255 trust
445461
# the connection (typically the Unix user name).
446462
#
447463
# TYPE DATABASE USER CIDR-ADDRESS METHOD
448-
host postgres all 192.168.93.0/24 ident sameuser
464+
host postgres all 192.168.93.0/24 ident sameuser
449465

450466
# Allow a user from host 192.168.12.10 to connect to database
451467
# "postgres" if the user's password is correctly supplied.
@@ -474,10 +490,10 @@ host all all 192.168.0.0/16 ident omicron
474490

475491
# If these are the only three lines for local connections, they will
476492
# allow local users to connect only to their own databases (databases
477-
# with the same name as their user name) except for administrators and
478-
# members of group "support" who may connect to all databases. The file
479-
# $PGDATA/admins contains a list of user names. Passwords are required in
480-
# all cases.
493+
# with the same name as their database user name) except for administrators
494+
# and members of role "support", who may connect to all databases. The file
495+
# $PGDATA/admins contains a list of names of administrators. Passwords
496+
# are required in all cases.
481497
#
482498
# TYPE DATABASE USER CIDR-ADDRESS METHOD
483499
local sameuser all md5
@@ -487,7 +503,7 @@ local all +support md5
487503
# The last two lines above can be combined into a single line:
488504
local all @admins,+support md5
489505

490-
# The database column can also use lists and file names, but not groups:
506+
# The database column can also use lists and file names:
491507
local db1,db2,@demodbs all md5
492508
</programlisting>
493509
</example>
@@ -506,7 +522,7 @@ local db1,db2,@demodbs all md5
506522
When <literal>trust</> authentication is specified,
507523
<productname>PostgreSQL</productname> assumes that anyone who can
508524
connect to the server is authorized to access the database with
509-
whatever database user they specify (including the database superuser).
525+
whatever database user name they specify (including superusers).
510526
Of course, restrictions made in the <literal>database</> and
511527
<literal>user</> columns still apply.
512528
This method should only be used when there is adequate
@@ -564,24 +580,26 @@ local db1,db2,@demodbs all md5
564580
The password-based authentication methods are <literal>md5</>,
565581
<literal>crypt</>, and <literal>password</>. These methods operate
566582
similarly except for the way that the password is sent across the
567-
connection. However, <literal>crypt</> does not allow encrypted
568-
passwords to be stored in <structname>pg_shadow</structname>.
583+
connection: respectively, MD5-hashed, crypt-encrypted, and clear-text.
584+
A limitation is that the <literal>crypt</> method does not work with
585+
passwords that have been encrypted in <structname>pg_authid</structname>.
569586
</para>
570587

571588
<para>
572589
If you are at all concerned about password
573590
<quote>sniffing</> attacks then <literal>md5</> is preferred, with
574591
<literal>crypt</> a second choice if you must support pre-7.2
575592
clients. Plain <literal>password</> should especially be avoided for
576-
connections over the open Internet (unless you use <acronym>SSL</acronym>, SSH, or
577-
other communications security wrappers around the connection).
593+
connections over the open Internet (unless you use <acronym>SSL</acronym>,
594+
<acronym>SSH</>, or another
595+
communications security wrapper around the connection).
578596
</para>
579597

580598
<para>
581599
<productname>PostgreSQL</productname> database passwords are
582600
separate from operating system user passwords. The password for
583-
each database user is stored in the <literal>pg_shadow</> system
584-
catalog table. Passwords can be managed with the SQL commands
601+
each database user is stored in the <literal>pg_authid</> system
602+
catalog. Passwords can be managed with the SQL commands
585603
<xref linkend="sql-createuser" endterm="sql-createuser-title"> and
586604
<xref linkend="sql-alteruser" endterm="sql-alteruser-title">,
587605
e.g., <userinput>CREATE USER foo WITH PASSWORD 'secret';</userinput>.
@@ -607,41 +625,44 @@ local db1,db2,@demodbs all md5
607625
<ulink url="http://www.nrl.navy.mil/CCS/people/kenh/kerberos-faq.html">
608626
Kerberos <acronym>FAQ</></ulink> or
609627
<ulink url="http://web.mit.edu/kerberos/www/">MIT Kerberos page</ulink>
610-
can be a good starting point for exploration.
628+
can be good starting points for exploration.
611629
Several sources for <productname>Kerberos</> distributions exist.
612630
</para>
613631

614632
<para>
615-
<productname>PostgreSQL</> supports Kerberos version 5, and it has
616-
to be enabled at build time. See
617-
<xref linkend="installation"> for more information.
633+
<productname>PostgreSQL</> supports Kerberos version 5. Kerberos
634+
support has to be enabled when <productname>PostgreSQL</> is built;
635+
see <xref linkend="installation"> for more information.
618636
</para>
619637

620638
<para>
621639
<productname>PostgreSQL</> operates like a normal Kerberos service.
622640
The name of the service principal is
623641
<literal><replaceable>servicename</>/<replaceable>hostname</>@<replaceable>realm</></literal>.
624-
</para>
625-
<para>
642+
</para>
643+
644+
<para>
626645
<replaceable>servicename</> can be set on the server side using the
627646
<xref linkend="guc-krb-srvname"> configuration parameter, and on the
628-
client side using the krbsrvname connection parameter. (See also <xref linkend="libpq-connect">.). The installation default can be changed from the default
629-
<literal>postgres</literal> at build time using
630-
<literal>./configure --with-krb-srvnam=whatever</>). In most environments,
631-
this parameter never needs to be changed. However, to support multiple
632-
<productname>PostgreSQL</> installations on the same host it is necessary.
633-
Some Kerberos implementations may also require a different service name,
634-
such as Microsoft Active Directory which requires the service name
635-
to be in uppercase (<literal>POSTGRES</literal>).
636-
</para>
637-
<para>
647+
client side using the <literal>krbsrvname</> connection parameter. (See
648+
also <xref linkend="libpq-connect">.) The installation default can be
649+
changed from the default <literal>postgres</literal> at build time using
650+
<literal>./configure --with-krb-srvnam=whatever</>. In most environments,
651+
this parameter never needs to be changed. However, to support multiple
652+
<productname>PostgreSQL</> installations on the same host it is necessary.
653+
Some Kerberos implementations may also require a different service name,
654+
such as Microsoft Active Directory which requires the service name
655+
to be in uppercase (<literal>POSTGRES</literal>).
656+
</para>
657+
658+
<para>
638659
<replaceable>hostname</> is the fully qualified host name of the
639660
server machine. The service principal's realm is the preferred realm
640661
of the server machine.
641662
</para>
642663

643664
<para>
644-
Client principals must have their <productname>PostgreSQL</> user
665+
Client principals must have their <productname>PostgreSQL</> database user
645666
name as their first component, for example
646667
<literal>pgusername/otherstuff@realm</>. At present the realm of
647668
the client is not checked by <productname>PostgreSQL</>; so if you
@@ -661,9 +682,9 @@ local db1,db2,@demodbs all md5
661682
</para>
662683

663684
<para>
664-
The keytab file is generated in the Kerberos system, see the
665-
Kerberos documentation for details. The following example is
666-
for MIT-compatible Kerberos 5 implementations:
685+
The keytab file is generated by the Kerberos software; see the
686+
Kerberos documentation for details. The following example is
687+
for MIT-compatible Kerberos 5 implementations:
667688
<screen>
668689
<prompt>kadmin% </><userinput>ank -randkey postgres/server.my.domain.org</>
669690
<prompt>kadmin% </><userinput>ktadd -k krb5.keytab postgres/server.my.domain.org</>
@@ -672,10 +693,10 @@ local db1,db2,@demodbs all md5
672693

673694
<para>
674695
When connecting to the database make sure you have a ticket for a
675-
principal matching the requested database user name. An example: For
696+
principal matching the requested database user name. For example, for
676697
database user name <literal>fred</>, both principal
677698
<literal>fred@EXAMPLE.COM</> and
678-
<literal>fred/users.example.com@EXAMPLE.COM</> can be used to
699+
<literal>fred/users.example.com@EXAMPLE.COM</> could be used to
679700
authenticate to the database server.
680701
</para>
681702

@@ -900,7 +921,7 @@ FATAL: no pg_hba.conf entry for host "123.123.123.123", user "andym", database
900921
This is what you are most likely to get if you succeed in contacting
901922
the server, but it does not want to talk to you. As the message
902923
suggests, the server refused the connection request because it found
903-
no authorizing entry in its <filename>pg_hba.conf</filename>
924+
no matching entry in its <filename>pg_hba.conf</filename>
904925
configuration file.
905926
</para>
906927

0 commit comments

Comments
 (0)