login_hook
login_hook - hook to execute login_hook.login() at login time
login_hook : login_hook - hook to execute login_hook.login() at login time
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 7360 | login_hook | login_hook | 1.7 |
SEC | GPL-3.0 | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-- | No | Yes | No | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | login_hook |
| See Also | pg_session_jwt pg_oidc_validator pgjwt oidc_validator pg_auth_mon auth_delay set_user pgsodium sslinfo sslutils |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | MIXED | 1.7 |
18 17 16 15 14 | login_hook |
- |
| RPM | PGDG | 1.7 |
18 17 16 15 14 | login_hook_$v |
- |
| DEB | PIGSTY | 1.7 |
18 17 16 15 14 | postgresql-$v-login-hook |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 1.7 | PGDG 1.7 | PGDG 1.7 | PGDG 1.7 | PGDG 1.7 |
| el8.aarch64 | PIGSTY 1.7 | PGDG 1.7 | PGDG 1.7 | PGDG 1.7 | PGDG 1.7 |
| el9.x86_64 | PIGSTY 1.7 | PGDG 1.7 | PGDG 1.7 | PGDG 1.7 | PGDG 1.7 |
| el9.aarch64 | PIGSTY 1.7 | PGDG 1.7 | PGDG 1.7 | PGDG 1.7 | PGDG 1.7 |
| el10.x86_64 | PIGSTY 1.7 | PGDG 1.7 | PGDG 1.7 | PGDG 1.7 | PGDG 1.7 |
| el10.aarch64 | PIGSTY 1.7 | PGDG 1.7 | PGDG 1.7 | PGDG 1.7 | PGDG 1.7 |
| d12.x86_64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| d12.aarch64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| d13.x86_64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| d13.aarch64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| u22.x86_64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| u22.aarch64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| u24.x86_64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| u24.aarch64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| u26.x86_64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
| u26.aarch64 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 | PIGSTY 1.7 |
Source
github.com/splendiddata/login_hook
login_hook-1.7.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
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