1/*-------------------------------------------------------------------------
2 *
3 * hba.h
4 * Interface to hba.c
5 *
6 *
7 * src/include/libpq/hba.h
8 *
9 *-------------------------------------------------------------------------
10 */
11#ifndef HBA_H
12#define HBA_H
13
14#include "libpq/pqcomm.h" /* pgrminclude ignore */ /* needed for NetBSD */
15#include "nodes/pg_list.h"
16#include "regex/regex.h"
17
18
19/*
20 * The following enum represents the authentication methods that
21 * are supported by PostgreSQL.
22 *
23 * Note: keep this in sync with the UserAuthName array in hba.c.
24 */
25typedef enum UserAuth
26{
27 uaReject,
28 uaImplicitReject, /* Not a user-visible option */
29 uaTrust,
30 uaIdent,
31 uaPassword,
32 uaMD5,
33 uaSCRAM,
34 uaGSS,
35 uaSSPI,
36 uaPAM,
37 uaBSD,
38 uaLDAP,
39 uaCert,
40 uaRADIUS,
41 uaPeer
42#define USER_AUTH_LAST uaPeer /* Must be last value of this enum */
43} UserAuth;
44
45typedef enum IPCompareMethod
46{
47 ipCmpMask,
48 ipCmpSameHost,
49 ipCmpSameNet,
50 ipCmpAll
51} IPCompareMethod;
52
53typedef enum ConnType
54{
55 ctLocal,
56 ctHost,
57 ctHostSSL,
58 ctHostNoSSL,
59 ctHostGSS,
60 ctHostNoGSS,
61} ConnType;
62
63typedef enum ClientCertMode
64{
65 clientCertOff,
66 clientCertCA,
67 clientCertFull
68} ClientCertMode;
69
70typedef struct HbaLine
71{
72 int linenumber;
73 char *rawline;
74 ConnType conntype;
75 List *databases;
76 List *roles;
77 struct sockaddr_storage addr;
78 struct sockaddr_storage mask;
79 IPCompareMethod ip_cmp_method;
80 char *hostname;
81 UserAuth auth_method;
82
83 char *usermap;
84 char *pamservice;
85 bool pam_use_hostname;
86 bool ldaptls;
87 char *ldapscheme;
88 char *ldapserver;
89 int ldapport;
90 char *ldapbinddn;
91 char *ldapbindpasswd;
92 char *ldapsearchattribute;
93 char *ldapsearchfilter;
94 char *ldapbasedn;
95 int ldapscope;
96 char *ldapprefix;
97 char *ldapsuffix;
98 ClientCertMode clientcert;
99 char *krb_realm;
100 bool include_realm;
101 bool compat_realm;
102 bool upn_username;
103 List *radiusservers;
104 char *radiusservers_s;
105 List *radiussecrets;
106 char *radiussecrets_s;
107 List *radiusidentifiers;
108 char *radiusidentifiers_s;
109 List *radiusports;
110 char *radiusports_s;
111} HbaLine;
112
113typedef struct IdentLine
114{
115 int linenumber;
116
117 char *usermap;
118 char *ident_user;
119 char *pg_role;
120 regex_t re;
121} IdentLine;
122
123/* kluge to avoid including libpq/libpq-be.h here */
124typedef struct Port hbaPort;
125
126extern bool load_hba(void);
127extern bool load_ident(void);
128extern void hba_getauthmethod(hbaPort *port);
129extern int check_usermap(const char *usermap_name,
130 const char *pg_role, const char *auth_user,
131 bool case_sensitive);
132extern bool pg_isblank(const char c);
133
134#endif /* HBA_H */
135