|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* hba.h
|
|
|
|
* Interface to hba.c
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* src/include/libpq/hba.h
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef HBA_H
|
|
|
|
#define HBA_H
|
|
|
|
|
|
|
|
#include "libpq/pqcomm.h" /* pgrminclude ignore */ /* needed for NetBSD */
|
|
|
|
#include "nodes/pg_list.h"
|
Parse pg_ident.conf when it's loaded, keeping it in memory in parsed format.
Similar changes were done to pg_hba.conf earlier already, this commit makes
pg_ident.conf to behave the same as pg_hba.conf.
This has two user-visible effects. First, if pg_ident.conf contains multiple
errors, the whole file is parsed at postmaster startup time and all the
errors are immediately reported. Before this patch, the file was parsed and
the errors were reported only when someone tries to connect using an
authentication method that uses the file, and the parsing stopped on first
error. Second, if you SIGHUP to reload the config files, and the new
pg_ident.conf file contains an error, the error is logged but the old file
stays in effect.
Also, regular expressions in pg_ident.conf are now compiled only once when
the file is loaded, rather than every time the a user is authenticated. That
should speed up authentication if you have a lot of regexps in the file.
Amit Kapila
13 years ago
|
|
|
#include "regex/regex.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following enum represents the authentication methods that
|
|
|
|
* are supported by PostgreSQL.
|
|
|
|
*
|
|
|
|
* Note: keep this in sync with the UserAuthName array in hba.c.
|
|
|
|
*/
|
|
|
|
typedef enum UserAuth
|
|
|
|
{
|
|
|
|
uaReject,
|
|
|
|
uaImplicitReject, /* Not a user-visible option */
|
|
|
|
uaTrust,
|
|
|
|
uaIdent,
|
|
|
|
uaPassword,
|
|
|
|
uaMD5,
|
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
8 years ago
|
|
|
uaSASL,
|
|
|
|
uaGSS,
|
|
|
|
uaSSPI,
|
|
|
|
uaPAM,
|
|
|
|
uaBSD,
|
|
|
|
uaLDAP,
|
|
|
|
uaCert,
|
|
|
|
uaRADIUS,
|
|
|
|
uaPeer
|
|
|
|
#define USER_AUTH_LAST uaPeer /* Must be last value of this enum */
|
|
|
|
} UserAuth;
|
|
|
|
|
|
|
|
typedef enum IPCompareMethod
|
|
|
|
{
|
|
|
|
ipCmpMask,
|
|
|
|
ipCmpSameHost,
|
|
|
|
ipCmpSameNet,
|
|
|
|
ipCmpAll
|
|
|
|
} IPCompareMethod;
|
|
|
|
|
|
|
|
typedef enum ConnType
|
|
|
|
{
|
|
|
|
ctLocal,
|
|
|
|
ctHost,
|
|
|
|
ctHostSSL,
|
|
|
|
ctHostNoSSL
|
|
|
|
} ConnType;
|
|
|
|
|
|
|
|
typedef struct HbaLine
|
|
|
|
{
|
|
|
|
int linenumber;
|
|
|
|
char *rawline;
|
|
|
|
ConnType conntype;
|
|
|
|
List *databases;
|
|
|
|
List *roles;
|
|
|
|
struct sockaddr_storage addr;
|
|
|
|
struct sockaddr_storage mask;
|
|
|
|
IPCompareMethod ip_cmp_method;
|
|
|
|
char *hostname;
|
|
|
|
UserAuth auth_method;
|
|
|
|
|
|
|
|
char *usermap;
|
|
|
|
char *pamservice;
|
|
|
|
bool pam_use_hostname;
|
|
|
|
bool ldaptls;
|
|
|
|
char *ldapserver;
|
|
|
|
int ldapport;
|
|
|
|
char *ldapbinddn;
|
|
|
|
char *ldapbindpasswd;
|
|
|
|
char *ldapsearchattribute;
|
|
|
|
char *ldapbasedn;
|
|
|
|
int ldapscope;
|
|
|
|
char *ldapprefix;
|
|
|
|
char *ldapsuffix;
|
|
|
|
bool clientcert;
|
|
|
|
char *krb_realm;
|
|
|
|
bool include_realm;
|
|
|
|
bool compat_realm;
|
|
|
|
bool upn_username;
|
|
|
|
char *radiusserver;
|
|
|
|
char *radiussecret;
|
|
|
|
char *radiusidentifier;
|
|
|
|
int radiusport;
|
|
|
|
} HbaLine;
|
|
|
|
|
Parse pg_ident.conf when it's loaded, keeping it in memory in parsed format.
Similar changes were done to pg_hba.conf earlier already, this commit makes
pg_ident.conf to behave the same as pg_hba.conf.
This has two user-visible effects. First, if pg_ident.conf contains multiple
errors, the whole file is parsed at postmaster startup time and all the
errors are immediately reported. Before this patch, the file was parsed and
the errors were reported only when someone tries to connect using an
authentication method that uses the file, and the parsing stopped on first
error. Second, if you SIGHUP to reload the config files, and the new
pg_ident.conf file contains an error, the error is logged but the old file
stays in effect.
Also, regular expressions in pg_ident.conf are now compiled only once when
the file is loaded, rather than every time the a user is authenticated. That
should speed up authentication if you have a lot of regexps in the file.
Amit Kapila
13 years ago
|
|
|
typedef struct IdentLine
|
|
|
|
{
|
|
|
|
int linenumber;
|
Parse pg_ident.conf when it's loaded, keeping it in memory in parsed format.
Similar changes were done to pg_hba.conf earlier already, this commit makes
pg_ident.conf to behave the same as pg_hba.conf.
This has two user-visible effects. First, if pg_ident.conf contains multiple
errors, the whole file is parsed at postmaster startup time and all the
errors are immediately reported. Before this patch, the file was parsed and
the errors were reported only when someone tries to connect using an
authentication method that uses the file, and the parsing stopped on first
error. Second, if you SIGHUP to reload the config files, and the new
pg_ident.conf file contains an error, the error is logged but the old file
stays in effect.
Also, regular expressions in pg_ident.conf are now compiled only once when
the file is loaded, rather than every time the a user is authenticated. That
should speed up authentication if you have a lot of regexps in the file.
Amit Kapila
13 years ago
|
|
|
|
|
|
|
char *usermap;
|
|
|
|
char *ident_user;
|
|
|
|
char *pg_role;
|
|
|
|
regex_t re;
|
Parse pg_ident.conf when it's loaded, keeping it in memory in parsed format.
Similar changes were done to pg_hba.conf earlier already, this commit makes
pg_ident.conf to behave the same as pg_hba.conf.
This has two user-visible effects. First, if pg_ident.conf contains multiple
errors, the whole file is parsed at postmaster startup time and all the
errors are immediately reported. Before this patch, the file was parsed and
the errors were reported only when someone tries to connect using an
authentication method that uses the file, and the parsing stopped on first
error. Second, if you SIGHUP to reload the config files, and the new
pg_ident.conf file contains an error, the error is logged but the old file
stays in effect.
Also, regular expressions in pg_ident.conf are now compiled only once when
the file is loaded, rather than every time the a user is authenticated. That
should speed up authentication if you have a lot of regexps in the file.
Amit Kapila
13 years ago
|
|
|
} IdentLine;
|
|
|
|
|
|
|
|
/* kluge to avoid including libpq/libpq-be.h here */
|
|
|
|
typedef struct Port hbaPort;
|
|
|
|
|
|
|
|
extern bool load_hba(void);
|
Parse pg_ident.conf when it's loaded, keeping it in memory in parsed format.
Similar changes were done to pg_hba.conf earlier already, this commit makes
pg_ident.conf to behave the same as pg_hba.conf.
This has two user-visible effects. First, if pg_ident.conf contains multiple
errors, the whole file is parsed at postmaster startup time and all the
errors are immediately reported. Before this patch, the file was parsed and
the errors were reported only when someone tries to connect using an
authentication method that uses the file, and the parsing stopped on first
error. Second, if you SIGHUP to reload the config files, and the new
pg_ident.conf file contains an error, the error is logged but the old file
stays in effect.
Also, regular expressions in pg_ident.conf are now compiled only once when
the file is loaded, rather than every time the a user is authenticated. That
should speed up authentication if you have a lot of regexps in the file.
Amit Kapila
13 years ago
|
|
|
extern bool load_ident(void);
|
|
|
|
extern void hba_getauthmethod(hbaPort *port);
|
|
|
|
extern int check_usermap(const char *usermap_name,
|
|
|
|
const char *pg_role, const char *auth_user,
|
|
|
|
bool case_sensitive);
|
|
|
|
extern bool pg_isblank(const char c);
|
|
|
|
|
|
|
|
#endif /* HBA_H */
|