login_hook
login_hook - hook to execute login_hook.login() at login time
Repository
splendiddata/login_hook
https://github.com/splendiddata/login_hook
Source
login_hook-1.7.tar.gz
login_hook-1.7.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
login_hook | 1.7 | SEC | GPL-3.0 | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 7360 | login_hook | No | Yes | No | Yes | No | No | login_hook |
| Related | pg_session_jwt pg_oidc_validator pgjwt oidc_validator pg_auth_mon auth_delay set_user pgsodium sslinfo sslutils |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | MIXED | 1.7 | 1817161514 | login_hook | - |
| RPM | PGDG | 1.7 | 1817161514 | login_hook_$v | - |
| DEB | PIGSTY | 1.7 | 1817161514 | postgresql-$v-login-hook | - |
Build
You can build the RPM / DEB packages for login_hook using pig build:
Install
You can install login_hook directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Install
pig
dnf
apt
Create Extension:
Usage
login_hook: Execute code on user login, comparable to Oracle’s after logon trigger
login_hook allows executing custom PL/pgSQL code whenever a user logs into the database.
Configuration
Add to postgresql.conf:
Creating the Login Function
Define a login_hook.login() function that will execute on every login:
The PUBLIC grant is required because the function runs for every connecting user.
Functions
| Function | Returns | Description |
|---|---|---|
login_hook.is_executing_login_hook() | boolean | Returns true only when called during login hook execution |
login_hook.get_login_hook_version() | text | Returns compiled version of login_hook |
login_hook.login() | void | User-provided function executed at login |
Important Notes
- The function is NOT invoked for background processes or during recovery mode
- Handle all exceptions within the function – failures will prevent normal users from logging in
- Superusers get a warning but can still log in when the function fails
- For PostgreSQL 17+, consider using the native login event trigger instead
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)