Question

In my pg_hba.conf, I need a single user to be allowed to connect from two completely different IP addresses (like work and home, for example).

Something like the following would be really nice:

host    all    my_awesome_user    151.123.45.67/0, 72.11.12.13/0    md5

Putting adding two entries (one for each IP doesn't work: postgres just sees the first entry, which ether matches or doesn't and completely ignores the second entry.

Any help would be appreciated.

Was it helpful?

Solution

Putting adding two entries (one for each IP doesn't work: postgres just sees the first entry, which ether matches or doesn't and completely ignores the second entry.

I don't believe that's true. PostgreSQL won't match it if the address is wrong, from the docs on pg_hba.conf

Each record specifies a connection type, a client IP address range (if relevant for the connection type), a database name, a user name, and the authentication method to be used for connections matching these parameters. The first record with a matching connection type, client address, requested database, and user name is used to perform authentication. There is no “fall-through” or “backup”: if one record is chosen and the authentication fails, subsequent records are not considered. If no record matches, access is denied.

If the client's address does not match, it continues looking for one that does.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top