1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-12 21:01:52 +03:00

Add a client authentication hook.

KaiGai Kohei, with minor cleanup of the comments by me.
This commit is contained in:
Robert Haas
2010-10-26 21:20:02 -04:00
parent 1fea0c05eb
commit 20709f8136
2 changed files with 13 additions and 0 deletions

View File

@ -216,6 +216,12 @@ static int CheckRADIUSAuth(Port *port);
*---------------------------------------------------------------- *----------------------------------------------------------------
*/ */
/*
* This hook allows plugins to get control following client authentication,
* but before the user has been informed about the results. It could be used
* to record login events, insert a delay after failed authentication, etc.
*/
ClientAuthentication_hook_type ClientAuthentication_hook = NULL;
/* /*
* Tell the user the authentication failed, but not (much about) why. * Tell the user the authentication failed, but not (much about) why.
@ -577,6 +583,9 @@ ClientAuthentication(Port *port)
break; break;
} }
if (ClientAuthentication_hook)
(*ClientAuthentication_hook)(port, status);
if (status == STATUS_OK) if (status == STATUS_OK)
sendAuthRequest(port, AUTH_REQ_OK); sendAuthRequest(port, AUTH_REQ_OK);
else else

View File

@ -24,4 +24,8 @@ extern char *pg_krb_realm;
extern void ClientAuthentication(Port *port); extern void ClientAuthentication(Port *port);
/* Hook for plugins to get control in ClientAuthentication() */
typedef void (*ClientAuthentication_hook_type)(Port *, int);
extern PGDLLIMPORT ClientAuthentication_hook_type ClientAuthentication_hook;
#endif /* AUTH_H */ #endif /* AUTH_H */