This article is half-done without your Comment! *** Please share your thoughts via Comment ***
If you do not know about the role of pg_hba.conf file, visit the below link.
PostgreSQL: How to Allow Remote Connection to Connect Database
PostgreSQL also has a one more file related user access permission and that is pg_ident.conf.
PostgreSQL provides Ident-based authentication and It works by obtaining the client’s operating system user name and using it as the allowed database user name with an optional user name mapping.
When we are using an external authentication system, system username might not be the same as database username.
To allow external authentication, We should map the system username with database username and we can also set a map name to hide the system username and database username related detail.
For example,
Go to the PostgreSQL data directory and Open pg_ident.conf file.
You can find below lines:
1 2 3 |
# Put your actual configuration here # ---------------------------------- # MAPNAME SYSTEM-USERNAME PG-USERNAME |
You can add value to map system username and database username:
1 2 3 4 |
# Put your actual configuration here # ---------------------------------- # MAPNAME SYSTEM-USERNAME PG-USERNAME User123 LinuxUser PGUser |
Once you map your system user and database user in pg_ident.conf file, you can use map name in pg_hba.conf file to allow external authentication.
Go to your PostgreSQL data directory and open a pg_hba.conf file.
You can add the map name of system user and database user in METHOD column.
For Example,
1 2 |
# TYPE DATABASE USER ADDRESS METHOD host all all 120.172.0.0/16 ident map=User123 |