python-pam is a Python module that provides an interface to the Pluggable Authentication Modules (PAM) system on Unix-like operating systems using ctypes. It enables Python applications to perform user authentication tasks by leveraging the underlying system's PAM configuration. The current version is 2.0.2. Releases are primarily driven by bug fixes and compatibility updates.
pip install python-pamVerified import paths — ran on the pinned version, not inferred.
Initializes the PAM authentication object and attempts to authenticate a user with provided credentials. The `authenticate()` method returns `True` or `False`, and additional details are available in `p.code` and `p.reason`.
Ensure your code checks for `True` or `False` return values from `authenticate()`. If specifically targeting 2.0.0, verify against the PAM constant, otherwise boolean is standard in 2.0.2+.
Design your application with appropriate privilege separation. For authenticating multiple users in a non-privileged context, consider an authentication stack like SSSD on Linux.
Migrate any Python 2 usage to Python 3 as future support is not guaranteed and actively discouraged.
Familiarize yourself with PAM configuration on your target system. Ensure the relevant PAM service (`/etc/pam.d/system-auth` or a custom service) is correctly configured for the desired authentication methods.
Deploy applications using `python-pam` only on Linux or other compatible Unix-like systems. For Windows authentication, consider alternative libraries or methods.