Startup message filter

A startup message packet is the first thing a Postgres client sends after connecting to Gallium Data. It contains the user's database login name, (usually) the name of the database to connect to, as well as other parameters which vary according to the type and version of the client.

This filter is invoked whenever a startup message is received from the database client, which is normally right at login time. This is the perfect place to tweak things a bit, or to reject the login. For instance, a common practice would be to look up information about the user in a separate system (like an LDAP directory) and to store that information in the connection context, to be used later when filtering a result set or modifying a request.


This filter takes no parameters. The JavaScript code is always executed.


The following variables will be defined in the context object:

If result.success is set to false, then the login will be rejected with the error message from the result object (or a generic error message if that's not set).


A simple example that rejects a specific user:"Startup message parameters are: " + context.packet.getParameters().toString());
if (context.packet.getParameter("user") === 'jdoe') {
context.result.success = false;
context.result.errorMessage = "No login for jdoe, sorry";
context.result.closeConnection = true;