Skip to content

Instantly share code, notes, and snippets.

@scottoffen
Last active December 9, 2015 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottoffen/5f687d958cc51de71042 to your computer and use it in GitHub Desktop.
Save scottoffen/5f687d958cc51de71042 to your computer and use it in GitHub Desktop.

Using NTLM in Node.js

Add a project dependency for express-ntlm. In your express configuration, require in this package.

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

Just before adding routes to the app (after all the body parsing and static references, etc.):

app.use(ntlm());

This will attach an ntlm property to the request object, making it available in all of your routes.

{
    DomainName: 'YOURDOMAIN',
    UserName: 'yourusername',
    Workstation: 'Computer-Name'
}

If windows authentication cannot be found, the browser will prompt you for credentials. If you do not supply credentials, no page will be displayed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment