Skip to content

Commit 20709f8

Browse files
committed
Add a client authentication hook.
KaiGai Kohei, with minor cleanup of the comments by me.
1 parent 1fea0c0 commit 20709f8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/backend/libpq/auth.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ static int CheckRADIUSAuth(Port *port);
216216
*----------------------------------------------------------------
217217
*/
218218

219+
/*
220+
* This hook allows plugins to get control following client authentication,
221+
* but before the user has been informed about the results. It could be used
222+
* to record login events, insert a delay after failed authentication, etc.
223+
*/
224+
ClientAuthentication_hook_type ClientAuthentication_hook = NULL;
219225

220226
/*
221227
* Tell the user the authentication failed, but not (much about) why.
@@ -577,6 +583,9 @@ ClientAuthentication(Port *port)
577583
break;
578584
}
579585

586+
if (ClientAuthentication_hook)
587+
(*ClientAuthentication_hook)(port, status);
588+
580589
if (status == STATUS_OK)
581590
sendAuthRequest(port, AUTH_REQ_OK);
582591
else

src/include/libpq/auth.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ extern char *pg_krb_realm;
2424

2525
extern void ClientAuthentication(Port *port);
2626

27+
/* Hook for plugins to get control in ClientAuthentication() */
28+
typedef void (*ClientAuthentication_hook_type)(Port *, int);
29+
extern PGDLLIMPORT ClientAuthentication_hook_type ClientAuthentication_hook;
30+
2731
#endif /* AUTH_H */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy