@128technology/authenticate-pam-prebuilt 中文文档教程

发布于 5年前 浏览 22 项目主页 更新于 3年前

authenticate-pam-prebuilt

NodeJS 的异步 PAM 身份验证。 这个存储库提供了 node-authenticate-pam 的预构建版本。

您很可能需要在大多数常见环境中以 root 身份运行它! 在我的系统 (openSUSE 12.1) 上以非 root 身份运行时,在 libpam 的某处发生了段错误! - 但在 openSUSE Leap 42.2 上似乎没问题

它试图通过以下改进取代以前和过时的 node-pam 扩展:

  • Allows to provide own service name, for example common-auth or any custom service name defined in /etc/pam.d
  • Allows to provide PAM_RHOST via 'remoteHost' option. It is used to provide remote network authentication that will skip any local only authentication methods like for example fingerprint reading.
  • Already mentioned utilization of libuv and node-gyp
  • Proper type checking in C++ code, it throws exception if bad types are given
  • In case of error it passes the error string containing both pam function and pam_strerror() results

Example

Simple usage

pam_start(2) 的默认服务名称是“登录”。

var pam = require('authenticate-pam');
pam.authenticate('myusername', 'mysecretpassword', function(err) {
    if(err) {
      console.log(err);
    }
    else {
      console.log("Authenticated!");
    }
  });

Usage with options:

适当的应用程序应该提供自己的服务名称。 示例服务位于 /etc/pam.d 中。 例如,查找 sshd 的服务名称文件。 要进行正确的网络身份验证,您还应该为选项参数提供 remoteHost 键。 它将作为 PAM_RHOST (pam_set_item(2)) 传递给 pam

var pam = require('authenticate-pam');
pam.authenticate('rush', 'mysecretpassword', function(err) {
    if(err) {
      console.log(err);
    }
    else {
      console.log("Authenticated!");
    }
}, {serviceName: 'myapp', remoteHost: 'localhost'});

Install

首先,您需要为您的发行版安装 PAM 库的开发版本。

Centos 和 RHELyum install pam-devel

Debian/Ubuntuapt-get install libpam0g-dev

debian6/maverick/natty: apt-get install libreadline5-dev

oneiric(以及任何更新版本,例如 Debian 7 或 Ubuntu 12.04)apt-get install libreadline-gplv2-dev

然后就可以安装模块了: npm 安装 authenticate-pam

authenticate-pam-prebuilt

Asynchronous PAM authentication for NodeJS. This repository provides prebuilt versions of node-authenticate-pam.

You will most likely need to run it as root in most common environments! Running as non-root on my system (openSUSE 12.1) made a segfault happen somewhere in libpam! - but seems ok on on openSUSE Leap 42.2

It tries to superseed the previous and outdated node-pam extension with the following improvements:

  • Allows to provide own service name, for example common-auth or any custom service name defined in /etc/pam.d
  • Allows to provide PAM_RHOST via 'remoteHost' option. It is used to provide remote network authentication that will skip any local only authentication methods like for example fingerprint reading.
  • Already mentioned utilization of libuv and node-gyp
  • Proper type checking in C++ code, it throws exception if bad types are given
  • In case of error it passes the error string containing both pam function and pam_strerror() results

Example

Simple usage

Default service_name for pam_start(2) is 'login'.

var pam = require('authenticate-pam');
pam.authenticate('myusername', 'mysecretpassword', function(err) {
    if(err) {
      console.log(err);
    }
    else {
      console.log("Authenticated!");
    }
  });

Usage with options:

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 (pam_set_item(2))

var pam = require('authenticate-pam');
pam.authenticate('rush', 'mysecretpassword', function(err) {
    if(err) {
      console.log(err);
    }
    else {
      console.log("Authenticated!");
    }
}, {serviceName: 'myapp', remoteHost: 'localhost'});

Install

First you need install the development version of PAM libraries for your distro.

Centos and RHEL: yum install pam-devel

Debian/Ubuntu: apt-get install libpam0g-dev

debian6/maverick/natty: apt-get install libreadline5-dev

oneiric (and any newer, eg. Debian 7 or Ubuntu 12.04): apt-get install libreadline-gplv2-dev

Then you can install the module: npm install authenticate-pam

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文