Giter VIP home page Giter VIP logo

express-ntlm's Introduction

express-ntlm

An express middleware to have basic NTLM-authentication in node.js.

Upgrading from 1.0: The fields for username, domain and workstation have different names now: UserName, DomainName, Workstation.

Active Directory support is heavily inspired by PyAuthenNTLM2.

install

$ npm install express-ntlm

example usage

var express = require('express'),
    ntlm = require('express-ntlm');

var app = express();

app.use(ntlm({
    debug: function() {
        var args = Array.prototype.slice.apply(arguments);
        console.log.apply(null, args);
    },
    domain: 'MYDOMAIN',
    domaincontroller: 'ldap://myad.example',
}));

app.all('*', function(request, response) {
    response.end(JSON.stringify(request.ntlm)); // {"DomainName":"MYDOMAIN","UserName":"MYUSER","Workstation":"MYWORKSTATION"}
});

app.listen(80);

without validation

It's not recommended, but it's possible to add NTLM-Authentication without validation. This means you can authenticate without providing valid credentials.

app.use(ntlm());

options

Name type default description
badrequest function function(request, response, next) { response.sendStatus(400); } Function to handle HTTP 400 Bad Request.
internalservererror function function(request, response, next) { response.sendStatus(500); } Function to handle 500 Internal Server Error.
forbidden function function(request, response, next) { response.sendStatus(403); } Function to handle HTTP 403 Forbidden.
prefix string [express-ntlm] The prefix is the first argument passed to the debug-function.
debug function function() {} Function to log the debug messages. See logging for more details.
domain string undefined Default domain if the DomainName-field cannot be parsed.
domaincontroller null / string / array null One or more domaincontroller(s) to handle the authentication. If null is specified the user is not validated. Active Directory is supported.
## logging (examples)
function() {
    var args = Array.prototype.slice.apply(arguments);
    console.log.apply(null, args);
}

logging to debug (or similiar logging-utilities)

function() {
    var args = Array.prototype.slice.apply(arguments);
    debug.apply(null, args.slice(1)); // slice the prefix away, since debug is already prefixed
}

notes

All NTLM-fields (UserName, DomainName, Workstartion) are also available within response.locals.ntlm, which means you can access it through your template engine (e.g. jade or ejs) when rendering using ntlm (e.g. <%= ntlm.UserName %>).

express-ntlm's People

Contributors

einfallstoll avatar arieteter avatar hbjcr avatar markhicken avatar

Watchers

 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.