]> granicus.if.org Git - postgresql/blob - src/backend/libpq/pg_hba.conf.sample
Add documentation changes for new pg_hba.conf behavior.
[postgresql] / src / backend / libpq / pg_hba.conf.sample
1
2 #                 PostgreSQL HOST-BASED ACCESS (HBA) CONTROL FILE
3
4
5 # This file controls:
6
7 #       o which hosts are allowed to connect
8 #       o how users are authenticated on each host
9 #       o databases accessible by each host
10
11 # It is read on postmaster startup and when the postmaster receives a SIGHUP.
12 # If you edit the file on a running system, you have to SIGHUP the postmaster
13 # for the changes to take effect.
14
15 # Each line is a new record. Records cannot be continued across multiple
16 # lines. Comments begin with # and continue to the end of the line. 
17 # Blank lines are ignored. A record consists of tokens separated by 
18 # multiple spaces or tabs.
19
20 # The first token of a record indicates its type. The remainder of the
21 # record is interpreted based on its type.
22
23 # Record Types
24 # ============
25
26 # There are three types of records:
27
28 #       o host
29 #       o hostssl
30 #       o local
31
32 # host
33 # ----
34
35 # This record identifies the networked hosts that are permitted to connect
36 # via IP connections.
37
38 # Format:
39
40 #   host  DBNAME  IP_ADDRESS  ADDRESS_MASK  AUTH_TYPE  [AUTH_ARGUMENT]
41
42 # DBNAME can be:
43
44 #       o the name of a PostgreSQL database
45 #       o "all" to indicate all databases
46 #       o "sameuser" to allow access only to databases with the same
47 #         name as the connecting user
48
49 # IP_ADDRESS and ADDRESS_MASK are standard dotted decimal IP address and
50 # mask values. IP addresses can only be specified numerically, not as
51 # domain or host names.
52
53 # AUTH_TYPE and AUTH_ARGUMENT are described below.
54
55 # There can be multiple "host" records, possibly with overlapping sets of
56 # host addresses. The postmaster finds the first entry that matches the
57 # connecting host IP address and the requested database name. If no entry
58 # matches the database/hostname combination, the connection is rejected.
59
60
61 # hostssl
62 # -------
63
64 # The format of this record is identical to "host".
65
66 # This record identifies a set of network hosts that are permitted to
67 # connect to databases over secure SSL IP connections. Note that a "host"
68 # record will also allow SSL connections.  "hostssl" forces these
69 # hosts to use *only* SSL-secured connections.
70
71 # This keyword is only available if the server was compiled with SSL
72 # support enabled.
73
74
75 # local
76 # -----
77
78 # This record identifies the authentication to use when connecting to
79 # the server via a local UNIX domain socket.  UNIX-socket connections are
80 # allowed only if this record type appears.
81
82 # Format:
83
84 #   local  DBNAME  AUTH_TYPE  [AUTH_ARGUMENT]
85
86 # This format is identical to the "host" record type except the IP_ADDRESS
87 # and ADDRESS_MASK fields are omitted.
88
89 # As with "host" records, the first "local" record matching the requested
90 # database name is used.
91
92
93
94 # Authentication Types (AUTH_TYPE)
95 # ================================
96
97 # AUTH_TYPE indicates the method used to authenticate users. The username
98 # is specified in the connection request.  A different AUTH_TYPE can be
99 # specified for each record in the file.
100
101 #   trust:      No authentication is done. Any valid username is accepted,
102 #               including the PostgreSQL superuser. This option should
103 #               be use only for machines where all users are truested.
104
105 #   password:   Authentication is done by matching a password supplied
106 #               in clear by the host. If no AUTH_ARGUMENT is used, the
107 #               password is compared with the user's entry in the
108 #               pg_shadow table.
109
110 #               If AUTH_ARGUMENT is specified, the username is looked up
111 #               in that file in the $PGDATA directory. If the username
112 #               exists but there is no password, the password is looked
113 #               up in pg_shadow. If a password exists in the file, it is
114 #               it used instead. These secondary files allow fine-grained
115 #               control over who can access which databases and whether
116 #               a non-default passwords are required. The same file can be
117 #               used in multiple records for easier administration.
118 #               Password files can be maintained with the pg_passwd(1)
119 #               utility. Remember, these passwords override pg_shadow
120 #               passwords.
121
122 #   crypt:      Same as "password", but authentication is done by
123 #               encrypting the password sent over the network. This is
124 #               always preferable to "password" except for old clients
125 #               that don't support "crypt". Also, crypt can use
126 #               usernames stored in secondary password files but not
127 #               secondary passwords.
128
129 #   ident:      Authentication is done by the ident server on the local
130 #               (127.0.0.1) or remote host. AUTH_ARGUMENT is required and
131 #               maps names found in the $PGDATA/pg_ident.conf file. The 
132 #               connection is accepted if the file contains an entry for
133 #               this map name with the ident-supplied username and the 
134 #               requested PostgreSQL username. The special map name 
135 #               "sameuser" indicates an implied map (not in pg_ident.conf)
136 #               that maps each ident username to the identical PostgreSQL 
137 #               username.
138
139 #   krb4:       Kerberos V4 authentication is used.
140
141 #   krb5:       Kerberos V5 authentication is used.
142
143 #   reject:     Reject the connection. This is used to reject certain hosts
144 #               that are part of a network specified later in the file.
145 #               To be effective, "reject" must appear before the later
146 #               entries.
147
148 # Local UNIX-domain socket connections support only the AUTH_TYPEs of
149 # "trust", "password", "crypt", and "reject".
150
151
152
153 # Examples
154 # ========
155
156
157 # Allow any user on the local system to connect to any database under any
158 # username using Unix-domain sockets (the default for local connections):
159 # TYPE       DATABASE    IP_ADDRESS    MASK               AUTH_TYPE  AUTH_ARGUMENT
160 # local      all                                          trust
161
162 # The same using IP connections on the same machine:
163 # TYPE       DATABASE    IP_ADDRESS    MASK               AUTH_TYPE  AUTH_ARGUMENT
164 # host       all         127.0.0.1     255.255.255.255    trust     
165
166 # Allow any user from any host with IP address 192.168.93.x to
167 # connect to database "template1" as the same username that ident reports
168 # for the connection (typically his Unix username):
169
170 # TYPE       DATABASE    IP_ADDRESS    MASK               AUTH_TYPE  AUTH_ARGUMENT
171 # host       template1   192.168.93.0  255.255.255.0      ident      sameuser
172
173 # Allow a user from host 192.168.12.10 to connect to database "template1"
174 # if the user's password in pg_shadow is correctly supplied:
175
176 # TYPE       DATABASE    IP_ADDRESS    MASK               AUTH_TYPE  AUTH_ARGUMENT
177 # host       template1   192.168.12.10 255.255.255.255    crypt
178
179 # In the absence of preceding "host" lines, these two lines will reject
180 # all connection from 192.168.54.1 (since that entry will be matched
181 # first), but allow Kerberos V5-validated connections from anywhere else
182 # on the Internet. The zero mask means that no bits of the host IP address
183 # are considered, so it matches any host:
184
185
186 # TYPE       DATABASE    IP_ADDRESS    MASK               AUTH_TYPE  AUTH_ARGUMENT
187 # host       all        192.168.54.1   255.255.255.255    reject
188 # host       all        0.0.0.0        0.0.0.0            krb5
189
190 # Allow users from 192.168.x.x hosts to connect to any database if they
191 # pass the ident check. For example, if ident says the user is "james" and
192 # he requests to connect as PostgreSQL user "guest", the connection is
193 # allowed if there is an entry in $PGDATA/pg_ident.conf with map name 
194 # "phoenix" that says "james" is allowed to connect as "guest":
195
196 # TYPE       DATABASE    IP_ADDRESS    MASK               AUTH_TYPE  AUTH_ARGUMENT
197 # host       all        192.168.0.0    255.255.0.0        ident      phoenix
198
199 # See $PGDATA/pg_ident.conf for more information on Ident maps.
200
201 # Put your actual configuration here
202 # ==================================
203
204 # This default configuration allows any local user to connect with any
205 # PostgreSQL username, over either UNIX domain sockets or IP:
206
207 # If you want to allow non-local connections, you will need to add more
208 # "host" records. Also, remember IP connections are only enabled if you
209 # start the postmaster with the -i option.
210
211 # CAUTION: if you are on a multiple-user machine, the default
212 # configuration is probably too liberal for you. Change it to use
213 # something other than "trust" authentication.
214
215 # TYPE     DATABASE    IP_ADDRESS    MASK               AUTH_TYPE  AUTH_ARGUMENT
216
217 local      all                                          trust
218 host       all         127.0.0.1     255.255.255.255    trust
219