amishmm / php-pam

This extension provides PAM (Pluggable Authentication Modules) integration for PHP
Other
10 stars 5 forks source link
pam pecl php-extension

API

bool pam_auth(string $username, string $password [, string &$error [, $checkacctmgmt = true [, string $servicename ] ] ]) bool pam_chpass(string $username, string $oldpassword, string $newpassword [, string &$error [, string $servicename ] ])

The parameters are

username - Username to check password - User supplied password error - Output parameter to put any error messages in checkacctmgmt - Call pam_acct_mgmt() to check account expiration and access hours (requires root access!) servicename - PAM service name to use (provided pam.force_servicename is not TRUE) oldpassword - Current password on account newpassword - Password to change to

INSTALLATION

For pam_auth and pam_chpass to work, module must know about the PAM service to use.

By default, the PAM service is set to "php". It can be changed by adding the following to your php.ini:

pam.servicename = "your-pam-service";

Service name can also be, optionally, passed as a parameter to pam_auth OR pam_chpass.

You can inform the module to ignore the service name passed as a parameter and use pam.servicename only, by adding the following to your php.ini:

pam.force_servicename = 1;

Next, you'll need to create a pam service file for php. If you are on linux, you'll need to create the file /etc/pam.d/php. You can copy another one to work off of (/etc/pam.d/login is a good choice).

Some examples that should work:

on linux:

/etc/pam.d/php

#

note: both an auth and account entry are required

auth sufficient /lib/security/pam_pwdb.so shadow nodelay account sufficient /lib/security/pam_pwdb.so

on solaris:

add to /etc/pam.conf

php auth requisite /usr/lib/security/pam_authtok_get.so.1 php auth required /usr/lib/security/pam_unix_auth.so.1 php account required /usr/lib/security/pam_unix_account.so.1

These would authenticate out of the unix password and shadow file. However please checking other /etc/pam.d/ entries, as the libraries these examples point to may not be correct.

FAQ