5
Processing the file
Records are read from top to bottom
The first record that corresponds to the attempted connection
(type, database, user, and address) is applied
authentication and verification of the CONNECT privilege are performed
if the result is negative, access is denied
if none of the records correspond to the connection parameters, access is
denied
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
The configuration file is processed from top to bottom. Each record is
matched against the parameters of the connection requested by the client
(by checking the connection type, database name, user name and IP
address). If a corresponding record is found, the authentication method
specified in the record is performed. Upon successful authentication, the
connection is permitted, otherwise it is denied (no other records are checked
after this point).
If no records correspond to the connection parameters, access is also
denied.
Thus, the records in the file should go from top to bottom from more specific
to more general.
At the bottom of the slide is a fragment of the default file you end up with
when building from source (may be different when installing from a
package). In this example, there are three records. The first one refers to
local non-TCP connections (local) for all databases (all) and users (all). The
second one is for remote connections (host) from the address 127.0.0.1
(localhost), and the third is the same, but for IPv6.
So, by default PostgreSQL allows only local connections (including local
network connections).
Some of the possible field values are discussed more closely later in this
topic.