Asynchronous PAM authentication for NodeJS
Default serviceName for is 'login'.
import pam from "@hoobs/pam";
pam.authenticate("username", "password", (error) => {
if (error) {
console.log(error);
} else {
console.log("authenticated");
}
});
Proper apps should provide their own service name. Sample services are located in /etc/pam.d
. As an example lookup a service name file for sshd
. To do proper network authentication you should also provide remoteHost
key to the options argument. It will be passed to pam as PAM_RHOST
.
import pam from "@hoobs/pam";
pam.authenticate("<username>", "<password>", (error) => {
if (error) {
console.log(errpr);
} else {
console.log("Authenticated!");
}
}, {
serviceName: "myapp",
remoteHost: "localhost",
});
First you will need to install PAM libraries.
sudo apt install libpam-dev
Then you can install this module into your project.
yarn add @hoobs/pam
This is a modified project orginally wrote by Damian Kaczmarek.
HOOBS and the HOOBS logo are registered trademarks of HOOBS Inc. Copyright (C) 2020 HOOBS Inc. All rights reserved.