]> granicus.if.org Git - postgresql/commitdiff
Add a client authentication hook.
authorRobert Haas <rhaas@postgresql.org>
Wed, 27 Oct 2010 01:20:02 +0000 (21:20 -0400)
committerRobert Haas <rhaas@postgresql.org>
Wed, 27 Oct 2010 01:20:38 +0000 (21:20 -0400)
KaiGai Kohei, with minor cleanup of the comments by me.

src/backend/libpq/auth.c
src/include/libpq/auth.h

index f9685c3a75e7c339520d6e005a15809b1a504fd6..146ebd72114781107ab88356900467dce03cf494 100644 (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.
@@ -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
index 00d4af5dcd6ef772b2d62fd1b2fcae4b0f392d49..32a0293dbd7e34cd3511ad8e4c3b23b0bcd79993 100644 (file)
@@ -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 */