↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Documentation / Extension Hooks / Authentication and connections

ClientAuthentication_hook

ClientAuthentication_hook

Hook for plugins to get control in ClientAuthentication()

Reading PostgreSQL 18.

Description

Hook for plugins to get control in ClientAuthentication()

Interface type
ClientAuthentication_hook_type
Header
src/include/libpq/auth.h
Subsystem
Authentication and connections
Initial value
NULL (no hook installed)

C interface

typedef void (*ClientAuthentication_hook_type) (Port *, int);
extern PGDLLIMPORT ClientAuthentication_hook_type ClientAuthentication_hook;

Core source comments

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.

Call sites

src/backend/libpq/auth.c:664

Core call context: src/backend/libpq/auth.c:658–672

					   "(%s:%d)",
					   port->user_name, hba_authname(port->hba->auth_method),
					   port->hba->sourcefile, port->hba->linenumber));
	}

	if (ClientAuthentication_hook)
		(*ClientAuthentication_hook) (port, status);

	if (status == STATUS_OK)
		sendAuthRequest(port, AUTH_REQ_OK, NULL, 0);
	else
		auth_failed(port, status, logdetail);
}

Documentation and source

Source build
Version
18
Build
REL_18_STABLE
Source fingerprint
753057e340da8f22e57c9a409ea7a235fd6a46bd

Related entries

Back to Extension Hooks · Recorded in PostgreSQL 10 through 20; the first sample is not necessarily its introduction.