Commit Graph

88 Commits

Author SHA1 Message Date
Michael Paquier 1b43743f11 Add description for new patterns supported in HBA and ident sample files
Support for regexps in database and role entries for pg_hba.conf has
been added in 8fea8683, and efb6f4a has extended support of pg-user in
pg_ident.conf, still both of them have missed a short description about
the new patterns supported in their respective sample files.

This commit closes the gap, by providing a short description of all the
new features supported for each entry type.

Reported-by: Pavel Luzanov
Reviewed-by: Jelte Fennema, Pavel Luzanov
Discussion: https://postgr.es/m/e495112d-8741-e651-64a2-ecb5728f1a56@postgrespro.ru
2023-02-16 07:38:52 +09:00
Michael Paquier a54b658ce7 Add support for file inclusions in HBA and ident configuration files
pg_hba.conf and pg_ident.conf gain support for three record keywords:
- "include", to include a file.
- "include_if_exists", to include a file, ignoring it if missing.
- "include_dir", to include a directory of files.  These are classified
by name (C locale, mostly) and need to be prefixed by ".conf", hence
following the same rules as GUCs.

This commit relies on the refactoring pieces done in efc9816, ad6c528,
783e8c6 and 1b73d0b, adding a small wrapper to build a list of
TokenizedAuthLines (tokenize_include_file), and the code is shaped to
offer some symmetry with what is done for GUCs with the same options.

pg_hba_file_rules and pg_ident_file_mappings gain a new field called
file_name, to track from which file a record is located, taking
advantage of the addition of rule_number in c591300 to offer an
organized view of the HBA or ident records loaded.

Bump catalog version.

Author: Julien Rouhaud
Reviewed-by: Michael Paquier
Discussion: https://postgr.es/m/20220223045959.35ipdsvbxcstrhya@jrouhaud
2022-11-24 13:51:34 +09:00
Peter Eisentraut 3a948ea0a2 pg_hba.conf.sample: Reword connection type section
Improve the wording in the connection type section of
pg_hba.conf.sample a bit.  After the hostgssenc part was added on, the
whole thing became a bit wordy, and it's also a bit inaccurate for
example in that the current wording for "host" appears to say that it
does not apply to GSS-encrypted connections.

Discussion: https://www.postgresql.org/message-id/flat/fc06dcc5-513f-e944-cd07-ba51dd7c6916%40enterprisedb.com
2021-04-29 07:00:20 +02:00
Bruce Momjian ac5852fb30 gss: add missing references to hostgssenc and hostnogssenc
These were missed when these were added to pg_hba.conf in PG 12;
updates docs and pg_hba.conf.sample.

Reported-by: Arthur Nascimento

Bug: 16380

Discussion: https://postgr.es/m/20200421182736.GG19613@momjian.us

Backpatch-through: 12
2020-05-25 20:19:28 -04:00
Heikki Linnakangas c727f120ff Rename "scram" to "scram-sha-256" in pg_hba.conf and password_encryption.
Per discussion, plain "scram" is confusing because we actually implement
SCRAM-SHA-256 rather than the original SCRAM that uses SHA-1 as the hash
algorithm. If we add support for SCRAM-SHA-512 or some other mechanism in
the SCRAM family in the future, that would become even more confusing.

Most of the internal files and functions still use just "scram" as a
shorthand for SCRMA-SHA-256, but I did change PASSWORD_TYPE_SCRAM to
PASSWORD_TYPE_SCRAM_SHA_256, as that could potentially be used by 3rd
party extensions that hook into the password-check hook.

Michael Paquier did this in an earlier version of the SCRAM patch set
already, but I didn't include that in the version that was committed.

Discussion: https://www.postgresql.org/message-id/fde71ff1-5858-90c8-99a9-1c2427e7bafb@iki.fi
2017-04-18 14:50:50 +03:00
Peter Eisentraut be37c2120a Enable replication connections by default in pg_hba.conf
initdb now initializes a pg_hba.conf that allows replication connections
from the local host, same as it does for regular connections.  The
connecting user still needs to have the REPLICATION attribute or be a
superuser.

The intent is to allow pg_basebackup from the local host to succeed
without requiring additional configuration.

Michael Paquier <michael.paquier@gmail.com> and me
2017-03-09 08:39:44 -05:00
Heikki Linnakangas 818fd4a67d Support SCRAM-SHA-256 authentication (RFC 5802 and 7677).
This introduces a new generic SASL authentication method, similar to the
GSS and SSPI methods. The server first tells the client which SASL
authentication mechanism to use, and then the mechanism-specific SASL
messages are exchanged in AuthenticationSASLcontinue and PasswordMessage
messages. Only SCRAM-SHA-256 is supported at the moment, but this allows
adding more SASL mechanisms in the future, without changing the overall
protocol.

Support for channel binding, aka SCRAM-SHA-256-PLUS is left for later.

The SASLPrep algorithm, for pre-processing the password, is not yet
implemented. That could cause trouble, if you use a password with
non-ASCII characters, and a client library that does implement SASLprep.
That will hopefully be added later.

Authorization identities, as specified in the SCRAM-SHA-256 specification,
are ignored. SET SESSION AUTHORIZATION provides more or less the same
functionality, anyway.

If a user doesn't exist, perform a "mock" authentication, by constructing
an authentic-looking challenge on the fly. The challenge is derived from
a new system-wide random value, "mock authentication nonce", which is
created at initdb, and stored in the control file. We go through these
motions, in order to not give away the information on whether the user
exists, to unauthenticated users.

Bumps PG_CONTROL_VERSION, because of the new field in control file.

Patch by Michael Paquier and Heikki Linnakangas, reviewed at different
stages by Robert Haas, Stephen Frost, David Steele, Aleksander Alekseev,
and many others.

Discussion: https://www.postgresql.org/message-id/CAB7nPqRbR3GmFYdedCAhzukfKrgBLTLtMvENOmPrVWREsZkF8g%40mail.gmail.com
Discussion: https://www.postgresql.org/message-id/CAB7nPqSMXU35g%3DW9X74HVeQp0uvgJxvYOuA4A-A3M%2B0wfEBv-w%40mail.gmail.com
Discussion: https://www.postgresql.org/message-id/55192AFE.6080106@iki.fi
2017-03-07 14:25:40 +02:00
Bruce Momjian 10c064ce4d Consistently mention 'SELECT pg_reload_conf()' in config files
Previously we only mentioned SIGHUP and 'pg_ctl reload' in
postgresql.conf and pg_hba.conf.
2016-10-25 11:26:15 -04:00
Magnus Hagander 98de86e422 Remove support for native krb5 authentication
krb5 has been deprecated since 8.3, and the recommended way to do
Kerberos authentication is using the GSSAPI authentication method
(which is still fully supported).

libpq retains the ability to identify krb5 authentication, but only
gives an error message about it being unsupported. Since all authentication
is initiated from the backend, there is no need to keep it at all
in the backend.
2014-01-19 17:05:01 +01:00
Peter Eisentraut 8a02339e9b initdb: Add options --auth-local and --auth-host
reviewed by Robert Haas and Pavel Stehule
2012-02-01 21:18:55 +02:00
Magnus Hagander 764bde0f16 Don't include local line on platforms without support
Since we now include a sample line for replication on local
connections in pg_hba.conf, don't include it where local
connections aren't available (such as on win32).

Also make sure we use authmethodlocal and not authmethod on
the sample line.
2011-05-30 20:21:06 +02:00
Peter Eisentraut f50655900a Add a "local" replication sample entry
Also adjust alignment a bit to distinguish commented out from comment.
2011-05-24 21:35:06 +03:00
Magnus Hagander a937b07121 Add example for replication in pg_hba.conf
Selena Deckelmann
2011-05-19 14:03:15 -04:00
Magnus Hagander 6f9192df61 Rename ident authentication over local connections to peer
This removes an overloading of two authentication options where
one is very secure (peer) and one is often insecure (ident). Peer
is also the name used in libpq from 9.1 to specify the same type
of authentication.

Also make initdb select peer for local connections when ident is
chosen, and ident for TCP connections when peer is chosen.

ident keyword in pg_hba.conf is still accepted and maps to peer
authentication.
2011-03-19 18:44:35 +01:00
Peter Eisentraut 24b29ca8f9 Support suffix matching of host names in pg_hba.conf
A name starting with a dot can be used to match a suffix of the actual
host name (e.g., .example.com matches foo.example.com).
2010-10-24 15:54:00 +03:00
Peter Eisentraut 6ab42ae367 Support host names in pg_hba.conf
Peter Eisentraut, reviewed by KaiGai Kohei and Tom Lane
2010-10-15 22:56:18 +03:00
Magnus Hagander b3daac5a9c Add support for RADIUS authentication. 2010-01-27 12:12:00 +00:00
Peter Eisentraut 525d2cbba2 Reformat the comments in pg_hba.conf and pg_ident.conf
These files have apparently been edited over the years by a dozen people
with as many different editor settings, which made the alignment of the
paragraphs quite inconsistent and ugly.  I made a pass of M-q with Emacs
to straighten it out.
2010-01-26 06:58:39 +00:00
Peter Eisentraut fd7673bc4e Make the default pg_hba.conf and pg_ident.conf align at 8-character boundaries
to make it easier to use with tabs.
2010-01-26 06:45:31 +00:00
Heikki Linnakangas 40f908bdcd Introduce Streaming Replication.
This includes two new kinds of postmaster processes, walsenders and
walreceiver. Walreceiver is responsible for connecting to the primary server
and streaming WAL to disk, while walsender runs in the primary server and
streams WAL from disk to the client.

Documentation still needs work, but the basics are there. We will probably
pull the replication section to a new chapter later on, as well as the
sections describing file-based replication. But let's do that as a separate
patch, so that it's easier to see what has been added/changed. This patch
also adds a new section to the chapter about FE/BE protocol, documenting the
protocol used by walsender/walreceivxer.

Bump catalog version because of two new functions,
pg_last_xlog_receive_location() and pg_last_xlog_replay_location(), for
monitoring the progress of replication.

Fujii Masao, with additional hacking by me
2010-01-15 09:19:10 +00:00
Tom Lane f3aec2c7f5 Support "samehost" and "samenet" specifications in pg_hba.conf,
by enumerating the machine's IP interfaces to look for a match.

Stef Walter
2009-10-01 01:58:58 +00:00
Tom Lane 7cdfa488c7 Remove last references to the crypt auth method, per Andreas Scherbaum. 2009-04-01 03:23:50 +00:00
Magnus Hagander f179d5ea99 Add support for using SSL client certificates to authenticate to the
database (only for SSL connections, obviously).
2008-11-20 11:48:26 +00:00
Magnus Hagander 7356381ef5 * make pg_hba authoption be a set of 0 or more name=value pairs
* make LDAP use this instead of the hacky previous method to specify
  the DN to bind as
* make all auth options behave the same when they are not compiled
  into the server
* rename "ident maps" to "user name maps", and support them for all
  auth methods that provide an external username

This makes a backwards incompatible change in the format of pg_hba.conf
for the ident, PAM and LDAP authentication methods.
2008-10-23 13:31:10 +00:00
Magnus Hagander f70866fb23 SSPI authentication on Windows. GSSAPI compatible client when doing Kerberos
against a Unix server, and Windows-specific server-side authentication
using SSPI "negotiate" method (Kerberos or NTLM).

Only builds properly with MSVC for now.
2007-07-23 10:16:54 +00:00
Magnus Hagander 6160106c74 Add support for GSSAPI authentication.
Documentation still being written, will be committed later.

Henry B. Hotz and Magnus Hagander
2007-07-10 13:14:22 +00:00
Bruce Momjian 638cc9abf8 Update pg_hba.conf comment about documentation section. 2006-10-11 23:01:46 +00:00
Bruce Momjian 357cc01e57 This patch adds native LDAP auth, for those platforms that don't have
PAM (such as Win32, but also unixen without PAM). On Unix, uses
OpenLDAP. On win32, uses the builin WinLDAP library.

Magnus Hagander
2006-03-06 17:41:44 +00:00
Neil Conway 6f8236f1b5 Fix typo in sample pg_hba.conf; per IRC report from Bernhard Neuhauser. 2005-10-11 22:58:15 +00:00
Tom Lane 2498d8296e Clean up some stray remaining references to pg_shadow, pg_user, pg_group. 2005-08-15 02:40:36 +00:00
Neil Conway a159ad3048 Remove support for Kerberos V4. It seems no one is using this, it has
some security issues, and upstream has declared it "dead". Patch from
Magnus Hagander, minor editorialization from Neil Conway.
2005-06-27 02:04:26 +00:00
Tom Lane 3b5152cac6 Improve comments in sample config files. 2005-01-07 23:59:17 +00:00
Bruce Momjian fa00650d8a Now that we advertize only CIDR address in pg_hba.conf, remove
duplicates sample entries from comments.
2004-11-06 05:32:05 +00:00
Bruce Momjian 4542581bf1 Adjustment to test on unix domain socket variable for pg_hba.conf
default settings, rather than just Win32.
2004-10-06 09:13:10 +00:00
Bruce Momjian c93872d891 Remove pg_hba.conf 'local' line for Win32 because it doesn't support unix domain
connections.

Andrew Dunstan
2004-10-06 09:01:18 +00:00
Bruce Momjian 32142e2a60 Update documentation to prefer CIDR format for pg_hba.conf and use new
CIDR column in examples first.
2004-08-26 16:50:05 +00:00
Bruce Momjian 8ec3221d32 Update Win32 wording. 2004-08-26 13:44:38 +00:00
Bruce Momjian d21eabc61a Remove Solaris bug mention in pg_hba.conf. 2004-08-21 03:21:57 +00:00
Bruce Momjian 009b0d1a85 >>At this stage of the game I would just change pg_hba.conf.sample to use
>>'127.0.0.1/32' instead of '127.0.0.1 255.255.255.255'.
>>
>>
>
>Yeah, that's probably the path of least resistance.  Note that the
>comments and possibly the SGML docs need to be adjusted to match,
>however, so it's not quite a one-liner.

Andrew Dunstan
2004-08-20 20:23:06 +00:00
Bruce Momjian e7029b2127 >I got a new idea on this. I think we should add an initdb option that
>takes a string to specify the local authentication method:
>
>       initdb --auth 'ident'
>
>or whatever the user wants.  I think this is more flexible and more
>compact.  It would default to 'trust', and the packagers could
>set it to
>whatever they want.  If their OS supports local ident, they can use
>that.
>
>Also keep in mind you might want some ident map file:
>
>       initdb --auth 'ident mymap'
>
>so you would need to allow multiple words in the string.

Magnus Hagander
2004-08-01 05:59:13 +00:00
Bruce Momjian 3e32e9476f Patch that makes quoting "sameuser", "samegroup", and "all" remove
special meaning of these terms in pg_hba.conf.

Also changes ugly pg_hba.conf IPv6 netmask of
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff to ::1/128.

Andrew Dunstan
2003-12-25 03:44:05 +00:00
Bruce Momjian c346ca8648 When I sent in the sslmode patch I forgot to update the
comments/examples in pg_hba.conf. This patch remedies that, adds a brief
explanation of the connection types, and adds a missing period in the
docs.

Jon Jensen
2003-09-13 16:43:38 +00:00
Tom Lane 7703e55c32 Make the default pg_hba.conf include an entry for ::1 only if configure
set HAVE_IPV6.  Per recent discussions.
2003-09-07 03:36:03 +00:00
Tom Lane 3c9bb8886d Allow IPv4-format entries in pg_hba.conf to match IPv6 connections
that have IPv4-embedded-in-IPv6 addresses.  Per idea of Andreas Pflug.
2003-09-05 20:31:36 +00:00
Tom Lane 17bb563abd Comment out entries for IPv6 localhost connections, since they fail
on machines with no IPv6 support.
2003-08-01 23:40:10 +00:00
Bruce Momjian e1be2ee831 Here's a small patch to pg_hba.conf.sample that explains the use of CIDR
addresses.

Andrew Dunstan
2003-06-25 01:15:24 +00:00
Bruce Momjian b4cea00a1f IPv6 cleanups.
Kurt Roeckx
Andrew Dunstan
2003-06-12 07:36:51 +00:00
Bruce Momjian c3e9699f21 Enable IPv6 connections to the server, and add pg_hba.conf IPv6 entries
if the OS supports it.  Code will still compile on non-IPv6-aware
machines (feature added by Bruce).

Nigel Kukard
2003-01-06 03:18:27 +00:00
Bruce Momjian 38ffbb95d5 Back out V6 code, caused postmaster startup failure. 2002-12-06 04:37:05 +00:00
Bruce Momjian 3bf160131d Updated IPv6 patch to fix netmask. 2002-12-06 03:49:19 +00:00