Commit 20709f81 authored by Robert Haas's avatar Robert Haas

Add a client authentication hook.

KaiGai Kohei, with minor cleanup of the comments by me.
parent 1fea0c05
...@@ -216,6 +216,12 @@ static int CheckRADIUSAuth(Port *port); ...@@ -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) ...@@ -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
......
...@@ -24,4 +24,8 @@ extern char *pg_krb_realm; ...@@ -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 */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment