Skip to content

Commit

Permalink
Yank signatures
Browse files Browse the repository at this point in the history
Fixes #11
  • Loading branch information
mattrobenolt committed Feb 21, 2013
1 parent ef1ce35 commit ac59746
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
3 changes: 1 addition & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ _.send = function send(kwargs) {
zlib.deflate(JSON.stringify(kwargs), function(err, buff) {
var message = buff.toString('base64'),
timestamp = new Date().getTime(),
signature = utils.getSignature(self.dsn.private_key, message, timestamp),
headers = {
'X-Sentry-Auth': utils.getAuthHeader(signature, timestamp, self.dsn.public_key, self.dsn.project_id),
'X-Sentry-Auth': utils.getAuthHeader(timestamp, self.dsn.public_key, self.dsn.project_id),
'Content-Type': 'application/octet-stream',
'Content-Length': message.length
};
Expand Down
9 changes: 1 addition & 8 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,8 @@ module.exports.constructChecksum = function constructChecksum(kwargs) {
return checksum.digest('hex');
};

module.exports.getSignature = function getSignature(key, message, timestamp) {
var hmac = crypto.createHmac('sha1', key);
hmac.update(timestamp+' '+message);
return hmac.digest('hex');
};

module.exports.getAuthHeader = function getAuthHeader(signature, timestamp, api_key, project_id) {
module.exports.getAuthHeader = function getAuthHeader(timestamp, api_key, project_id) {
var header = ['Sentry sentry_version=2.0'];
header.push('sentry_signature='+signature);
header.push('sentry_timestamp='+timestamp);
header.push('sentry_client=raven-node/'+raven.version);
header.push('sentry_key='+api_key);
Expand Down
13 changes: 3 additions & 10 deletions test/raven.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ describe('raven.utils', function() {
});
});

describe('#getSignature()', function(){
it('should sign a key, timestamp, and message with md5 hash', function(){
raven.utils.getSignature('abc', 'This is awesome!', 1331932297938).should.equal('76cfb41aa49f91e5eb4ffbb1fe0c5b578459c537');
});
});

describe('#parseDSN()', function(){
it('should parse hosted Sentry DSN without path', function(){
var dsn = raven.utils.parseDSN('https://8769c40cf49c4cc58b51fa45d8e2d166:296768aa91084e17b5ac02d3ad5bc7e7@app.getsentry.com/269');
Expand Down Expand Up @@ -106,12 +100,11 @@ describe('raven.utils', function() {

describe('#parseAuthHeader()', function(){
it('should parse all parameters', function(){
var signature = 'abc',
timestamp = 12345,
var timestamp = 12345,
api_key = 'xyz',
project_id = 1;
var expected = 'Sentry sentry_version=2.0, sentry_signature=abc, sentry_timestamp=12345, sentry_client=raven-node/'+raven.version+', sentry_key=xyz, project_id=1';
raven.utils.getAuthHeader(signature, timestamp, api_key, project_id).should.equal(expected);
var expected = 'Sentry sentry_version=2.0, sentry_timestamp=12345, sentry_client=raven-node/'+raven.version+', sentry_key=xyz, project_id=1';
raven.utils.getAuthHeader(timestamp, api_key, project_id).should.equal(expected);
});
});

Expand Down

0 comments on commit ac59746

Please sign in to comment.