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.