diff --git a/demo/providerDemo.js b/demo/providerDemo.js index 3eecbcc..c33d701 100644 --- a/demo/providerDemo.js +++ b/demo/providerDemo.js @@ -20,12 +20,16 @@ var ServerosServiceProvider = require('../src/classes/ServerosServiceProvider') , authenticator = new HawkAuthenticator(); ; -application.use('/authenticate', bodyParser.json()); +application.use(bodyParser.json()); application.post('/authenticate', provider.expressValidator(authenticator.credentialsAccepter())); application.use(authenticator.expressAuthorizer()); application.get('/test', function(req, res, next) { res.json({'Authed As': req.authedAs, 'Auth Data': req.authData}); }); +application.post('/test', function(req, res, next) { + res.send(); + console.log({'Authed As': req.authedAs, 'Auth Data': req.authData, 'Payload': req.body}); +}); var server = application.listen(3501, 'localhost', function () { var host = server.address().address; var port = server.address().port; diff --git a/package.json b/package.json index 9c8ac60..1a4d46b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "serveros", - "version": "0.2.3", + "version": "0.2.4", "description": "Auth for networks of applications.", "repository": { "type": "git", diff --git a/src/classes/HawkAuthenticator.js b/src/classes/HawkAuthenticator.js index cf708a2..86fb2e2 100644 --- a/src/classes/HawkAuthenticator.js +++ b/src/classes/HawkAuthenticator.js @@ -81,8 +81,13 @@ HawkAuthenticator.prototype = { Hawk.server.authenticate(req, function(id, callback) { that.storage.retrieve(id, function(credentials) { if (!credentials) { - callback("No Credentials Found."); - return; + callback("No Credentials Found."); + return; + } + if (Date.now() < credentials.expires) { + that.storage.purge(id, function() { + if (callback) callback("Credentials Expired"); + }); } var hawkCredentials = { key: credentials.secret diff --git a/src/classes/ServerosConsumer.js b/src/classes/ServerosConsumer.js index 0fa4999..3b7e956 100644 --- a/src/classes/ServerosConsumer.js +++ b/src/classes/ServerosConsumer.js @@ -212,6 +212,7 @@ ServerosConsumer.prototype.authorize = function(serviceLocation, ticket, callbac , id: ticket.id , key: ticket.secret , algorithm: ticket.hash + , expires: ticket.expires }); } });