diff --git a/README.md b/README.md
index d41bf91..8a1bff1 100644
--- a/README.md
+++ b/README.md
@@ -32,8 +32,9 @@ app.configure(function () {
var nodeSSPIObj = new nodeSSPI({
retrieveGroups: true
});
- nodeSSPIObj.authenticate(req, res);
- res.finished || next();
+ nodeSSPIObj.authenticate(req, res, function(err){
+ res.finished || next();
+ });
});
app.use(function (req, res, next) {
var out = 'Hello ' + req.connection.user + '! You belong to following groups:
';
@@ -102,7 +103,7 @@ The call to `new nodeSSPI(opts)` in above code can take following options:
* 403 if max login attempts are reached
* 401 for all in-progress authentications, including protocols that require multiple round trips or if max login attempts has not been reached.
* 500 when NodeSSPI encountered exception it cannot handle.
- * If option `authoritative` is not set to *true*, then response headers and `res.statusCode` will still be populated as described above, but NodeSSPI will not block the request, i.e. it will not call `res.end()`. Also, error message will be returned from calling `nodeSSPIObj.authenticate(req, res);` rather than sending to response. This allows the caller and downstream middleware to make decision.
+ * If option `authoritative` is not set to *true*, then response headers and `res.statusCode` will still be populated as described above, but NodeSSPI will not block the request, i.e. it will not call `res.end()`. Also, error message will be returned from calling `nodeSSPIObj.authenticate(req, res, cb(err){});` in the *err* callback parameter rather than sending to response. This allows the caller and downstream middleware to make decision.
## Platforms
NodeSSPI has been tested working on these Windows platforms:
diff --git a/index.js b/index.js
index 190721e..c9577c5 100644
--- a/index.js
+++ b/index.js
@@ -40,7 +40,7 @@ function main(opts) {
this.opts = opts;
}
-main.prototype.authenticate = function (req, res) {
+main.prototype.authenticate = function (req, res, cb) {
if (this.opts.perRequestAuth) {
delete req.connection.user;
}
@@ -49,14 +49,17 @@ main.prototype.authenticate = function (req, res) {
} catch (ex) {
if (this.opts.authoritative) {
res.end(ex);
+ cb();
return;
} else {
- return ex;
+ cb(ex);
+ return;
}
}
if (this.opts.authoritative && req.connection.user === undefined) {
res.end();
}
+ cb();
}
module.exports = main;
\ No newline at end of file
diff --git a/package.json b/package.json
index 27fee59..441fb76 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "node-sspi",
- "version": "0.0.4",
+ "version": "0.1.0",
"description": "Windows SSPI server-side authentication for Node",
"main": "index.js",
"author": "Fred Wen",