Enable "pam" authentication support via HBA#326
Conversation
petere
left a comment
There was a problem hiding this comment.
You need to update all the places where cf_auth_type == AUTH_PAM is checked. See src/objects.c and src/admin.c for missing places. The problem is that without these changes the takeover does not work correctly when you have a pg_hba.conf with mixed pam and on-pam entries. use_server_socket() in src/objects.c needs to decide when processing a server socket entry from SHOW FDS whether to look up the user in the normal user list or add it to the PAM user list. Right now it knows this from the global auth_type setting, because it's the same for all sockets. But if we allow a mix of PAM and non-PAM authentication, then we have to solve this in another way. I think a good way to do this would be to change SHOW FDS to ship a flag "this is a PAM user". (Updating the SHOW FDS output needs to be done with care to allow cross-version upgrades. I'm not sure about how to do that in detail.)
doc/config.md
Outdated
|
|
||
| pam | ||
| : PAM is used to authenticate users, `auth_file` is ignored. This method is not | ||
| PAM is used to authenticate users, `auth_file` is ignored. This method is not |
src/client.c
Outdated
| return false; | ||
| } | ||
|
|
||
| if (cf_auth_type == AUTH_HBA) |
There was a problem hiding this comment.
This information is already available in client->client_auth_type. No need to look it up again.
|
In a more general way: Just thinking out freely, this may be wrong, but..: A possible limitation: |
This exists, it's called pam-pgsql. But I don't see what this has to do with this thread. If you do PAM authentication and use pam-pgsql for the PAM module, then you are mostly just replicating what |
|
as i understand it: pam-psql in this form has little added value; just as you mention. what i mean: a pam module to check whether a user can authenticate against a postgresql cluster X, thus effectively authenticated against the pg_hba.conf of this postgresql cluster X; the problem at hand to be solved is that the authentication methods for pgbouncer do not match 100% the authentication methods of postgresql, or a combination of them. So instead of adding auth methods to pgbouncer, maybe just one is enough, |
|
I've studied this a bit today. One major issue that I have identified is how authenticating the same user sometimes via PAM and sometimes not works. Internally, PgBouncer tracks PAM and non-PAM users separately (see I think one way to move forward here would be to analyze whether we can get rid of |
|
Given that #1052 changed the user management it should now be fine to have PAM users and non-PAM users in one system. The So I decided to update this patch and address the other feedback from @petere. I intend to merge this soon given its simplicity. |
Cursory code review has shown no reason why "pam" should not be supported in pg_hba. Add "pam" to the list of supported authentication methods in the HBA file - only if generally available, of course - and edit docs to match the new reality. Fixes pgbouncer#501 Co-authored-by: Jelte Fennema-Nio <github-tech@jeltef.nl>
|
client->client_auth_type is not set until |
This reverts commit f856951. As reported in pgbouncer#1261 this broke PAM authentication completely, so I'm reverting this. I won't be touching PAM code anymore until someone adds some automated tests.
|
Ohh I see the patch is reverted in #1291 |
Cursory code review has shown no reason why "pam" should not be
supported in pg_hba.
Add "pam" to the list of supported authentication methods in
the HBA file - only if generally available, of course - and
edit docs to match the new reality.
Fixes #501