summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas2010-10-27 01:20:02 +0000
committerRobert Haas2010-10-27 01:20:38 +0000
commit20709f813601976076a346c0b0f8e92006e3b3fa (patch)
tree33fe43b3e0d20ca8b37f6829cc667a957a908d18
parent1fea0c05eb4ac4a21d79471b9a7fe96163306b88 (diff)
Add a client authentication hook.
KaiGai Kohei, with minor cleanup of the comments by me.
-rw-r--r--src/backend/libpq/auth.c9
-rw-r--r--src/include/libpq/auth.h4
2 files changed, 13 insertions, 0 deletions
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index f9685c3a75..146ebd7211 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -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.
@@ -577,6 +583,9 @@ ClientAuthentication(Port *port)
break;
}
+ if (ClientAuthentication_hook)
+ (*ClientAuthentication_hook)(port, status);
+
if (status == STATUS_OK)
sendAuthRequest(port, AUTH_REQ_OK);
else
diff --git a/src/include/libpq/auth.h b/src/include/libpq/auth.h
index 00d4af5dcd..32a0293dbd 100644
--- a/src/include/libpq/auth.h
+++ b/src/include/libpq/auth.h
@@ -24,4 +24,8 @@ extern char *pg_krb_realm;
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 */