Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
authenticatePayloadHash()
Browse files Browse the repository at this point in the history
  • Loading branch information
Eran Hammer committed Jan 8, 2014
1 parent ab965ed commit 0a9ecc2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
13 changes: 13 additions & 0 deletions lib/server.js
Expand Up @@ -219,6 +219,19 @@ exports.authenticatePayload = function (payload, credentials, artifacts, content
};


// Authenticate payload hash - used when payload cannot be provided during authenticate()

/*
calculatedHash: the payload hash calculated using Crypto.calculatePayloadHash()
artifacts: from authenticate callback
*/

exports.authenticatePayloadHash = function (calculatedHash, artifacts) {

return Cryptiles.fixedTimeComparison(calculatedHash, artifacts.hash);
};


// Generate a Server-Authorization header for a given response

/*
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "hawk",
"description": "HTTP Hawk Authentication Scheme",
"version": "2.0.0",
"version": "2.1.0",
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)",
"contributors": [],
"repository": "git://github.com/hueniverse/hawk",
Expand Down
10 changes: 10 additions & 0 deletions test/server.js
Expand Up @@ -682,5 +682,15 @@ describe('Hawk', function () {
done();
});
});

describe('#authenticatePayloadHash', function () {

it('checks payload hash', function (done) {

expect(Hawk.server.authenticatePayloadHash('abcdefg', { hash: 'abcdefg' })).to.equal(true);
expect(Hawk.server.authenticatePayloadHash('1234567', { hash: 'abcdefg' })).to.equal(false);
done();
});
});
});
});

0 comments on commit 0a9ecc2

Please sign in to comment.