Git Product home page Git Product logo

node-authenticate-pam's Introduction

node-authenticate-pam

Asynchronous PAM authentication for NodeJS 0.10 and 0.12

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!

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

npm install authenticate-pam

node-authenticate-pam's People

Contributors

evan-a-a avatar jcheng5 avatar rush avatar srossross avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.