node-auth-rest-server
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -70,8 +70,4 @@ 'use strict'; | ||
function isAuthorizedUrl(url){ | ||
return url.indexOf(authorizedUrlPrefix) == 0; | ||
} | ||
function authenticateWithRestToken(req, res, next){ | ||
if(isAuthorizedUrl(req.url)){ | ||
if(authRestMethods.isAuthorizedUrl(req.url)){ | ||
if(!req.headers.authorization || !req.headers.authorization.split('=')[1]){ | ||
@@ -78,0 +74,0 @@ res.status(401).set({'Content-Type': 'text/plain', 'Content-Length': '0', 'WWW-Authenticate': 'Token realm="Application"'}).end(); |
@@ -5,3 +5,3 @@ { | ||
"description": "Provides a basic token authentication, and auto generation of authentication token", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "url": "" |
@@ -47,2 +47,6 @@ # AuthRestServer | ||
callback(err, authToken); | ||
}, | ||
isAuthorizedUrl: function(url){ | ||
// e.g. | ||
// return url.indexOf('/api/secret/') == 0; | ||
} | ||
@@ -59,5 +63,5 @@ }; | ||
var authRest = require('node-auth-rest-server'); | ||
app.use(authRest(app, authRestMethods, '/api/secret/')); | ||
app.use(authRest(app, authRestMethods)); | ||
``` | ||
* if the url doesn't start with the prefix, then the middleware doesn't performs the following steps and just calls `next` | ||
* if the `authRestMethods.isAuthorizedUrl(url)` returns false, then the middleware doesn't perform the following steps and just calls `next` | ||
* if the header doeasn't contain any token then the request ends with respond 401 | ||
@@ -64,0 +68,0 @@ * calls `authRestMethods.getValidTokenByKey` with the token from the header and in it's callback checks the value |
6869
72
74