Comparing version 2.3.0 to 2.3.1
@@ -351,3 +351,3 @@ // Load modules | ||
if (request.authorization) { | ||
return callback(Boom.badRequest('Multiple authentications', 'Hawk')); | ||
return callback(Boom.badRequest('Multiple authentications')); | ||
} | ||
@@ -354,0 +354,0 @@ |
{ | ||
"name": "hawk", | ||
"description": "HTTP Hawk Authentication Scheme", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)", | ||
@@ -26,3 +26,4 @@ "contributors": [], | ||
"devDependencies": { | ||
"lab": "4.x.x" | ||
"code": "1.x.x", | ||
"lab": "5.x.x" | ||
}, | ||
@@ -29,0 +30,0 @@ "scripts": { |
@@ -40,2 +40,3 @@ ![hawk Logo](https://raw.github.com/hueniverse/hawk/master/images/hawk.png) | ||
<p></p> | ||
- [**Implementations**](#implementations) | ||
- [**Acknowledgements**](#acknowledgements) | ||
@@ -605,3 +606,3 @@ | ||
used or reused for a purpose other than what they were created for (i.e. prevents switching MAC values between a request, | ||
response, and a bewit use cases). It also protects against expliots created after a potential change in how the protocol | ||
response, and a bewit use cases). It also protects against exploits created after a potential change in how the protocol | ||
creates the normalized string. For example, if a future version would switch the order of nonce and timestamp, it | ||
@@ -622,3 +623,9 @@ can create an exploit opportunity for cases where the nonce is similar in format to a timestamp. | ||
# Implementations | ||
- [Logibit Hawk in F#/.Net](https://github.com/logibit/logibit.hawk/) | ||
- [Tent Hawk in Ruby](https://github.com/tent/hawk-ruby) | ||
- [Wealdtech in Java](https://github.com/wealdtech/hawk) | ||
- [Kumar's Mohawk in Python](https://github.com/kumar303/mohawk/) | ||
# Acknowledgements | ||
@@ -625,0 +632,0 @@ |
// Load modules | ||
var Url = require('url'); | ||
var Code = require('code'); | ||
var Hawk = require('../lib'); | ||
var Hoek = require('hoek'); | ||
var Lab = require('lab'); | ||
var Hoek = require('hoek'); | ||
var Hawk = require('../lib'); | ||
var Browser = require('../lib/browser'); | ||
@@ -20,3 +21,3 @@ | ||
var it = lab.test; | ||
var expect = Lab.expect; | ||
var expect = Code.expect; | ||
@@ -54,3 +55,3 @@ | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -79,3 +80,3 @@ expect(attributes.ext).to.equal('some-app-data'); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -250,7 +251,7 @@ done(); | ||
req.authorization = Browser.client.header('http://example.com:8080/resource/4?filter=a', req.method, { credentials: credentials, ext: 'some-app-data' }).field; | ||
expect(req.authorization).to.exist; | ||
expect(req.authorization).to.exist(); | ||
Hawk.server.authenticate(req, credentialsFunc, {}, function (err, credentials, artifacts) { | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -283,3 +284,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -300,3 +301,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
res.headers['server-authorization'] = Hawk.server.header(credentials, artifacts, { payload: 'some reply', contentType: 'text/plain', ext: 'response-specific' }); | ||
expect(res.headers['server-authorization']).to.exist; | ||
expect(res.headers['server-authorization']).to.exist(); | ||
@@ -329,3 +330,3 @@ expect(Browser.client.authenticate(res, credentials, artifacts, { payload: 'some reply' })).to.equal(true); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -346,3 +347,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
res.headers['server-authorization'] = Hawk.server.header(credentials, artifacts, { payload: 'some reply', contentType: 'text/plain', ext: 'response-specific' }); | ||
expect(res.headers['server-authorization']).to.exist; | ||
expect(res.headers['server-authorization']).to.exist(); | ||
@@ -367,7 +368,7 @@ expect(Browser.client.authenticate(res, credentials, artifacts, { payload: 'some reply' })).to.equal(true); | ||
req.authorization = Browser.client.header('http://example.com:8080/resource/4?filter=a', req.method, { credentials: credentials, ext: 'some-app-data', localtimeOffsetMsec: 100000 }).field; | ||
expect(req.authorization).to.exist; | ||
expect(req.authorization).to.exist(); | ||
Hawk.server.authenticate(req, credentialsFunc, { localtimeOffsetMsec: 100000 }, function (err, credentials, artifacts) { | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -400,3 +401,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -417,3 +418,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
res.headers['server-authorization'] = Hawk.server.header(credentials, artifacts); | ||
expect(res.headers['server-authorization']).to.exist; | ||
expect(res.headers['server-authorization']).to.exist(); | ||
@@ -446,3 +447,3 @@ expect(Browser.client.authenticate(res, credentials, artifacts)).to.equal(true); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -482,7 +483,7 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
req.authorization = header.field; | ||
expect(req.authorization).to.exist; | ||
expect(req.authorization).to.exist(); | ||
Hawk.server.authenticate(req, credentialsFunc, {}, function (err, credentials, artifacts) { | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Stale timestamp'); | ||
@@ -505,7 +506,7 @@ | ||
req.authorization = Browser.client.header('http://example.com:8080/resource/4?filter=a', req.method, { credentials: credentials, ext: 'some-app-data' }).field; | ||
expect(req.authorization).to.exist; | ||
expect(req.authorization).to.exist(); | ||
Hawk.server.authenticate(req, credentialsFunc, {}, function (err, credentials, artifacts) { | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -537,7 +538,7 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
req.authorization = header.field; | ||
expect(req.authorization).to.exist; | ||
expect(req.authorization).to.exist(); | ||
Hawk.server.authenticate(req, credentialsFunc, {}, function (err, credentials, artifacts) { | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Stale timestamp'); | ||
@@ -562,7 +563,7 @@ | ||
req.authorization = Browser.client.header('http://example.com:8080/resource/4?filter=a', req.method, { credentials: credentials, ext: 'some-app-data' }).field; | ||
expect(req.authorization).to.exist; | ||
expect(req.authorization).to.exist(); | ||
Hawk.server.authenticate(req, credentialsFunc, {}, function (err, credentials, artifacts) { | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -596,3 +597,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -613,3 +614,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
res.headers['server-authorization'] = Hawk.server.header(credentials, artifacts); | ||
expect(res.headers['server-authorization']).to.exist; | ||
expect(res.headers['server-authorization']).to.exist(); | ||
@@ -636,3 +637,3 @@ expect(Browser.client.authenticate(res, credentials, artifacts, { payload: 'some reply' })).to.equal(false); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -659,7 +660,7 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
expect(artifacts.ext).to.equal('some-app-data'); | ||
expect(Hawk.server.authenticatePayload('hola!', credentials, artifacts)).to.be.true; | ||
expect(Hawk.server.authenticatePayload('hello!', credentials, artifacts)).to.be.false; | ||
expect(Hawk.server.authenticatePayload('hola!', credentials, artifacts)).to.be.true(); | ||
expect(Hawk.server.authenticatePayload('hello!', credentials, artifacts)).to.be.false(); | ||
done(); | ||
@@ -684,3 +685,3 @@ }); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -708,3 +709,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -733,3 +734,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Bad payload hash'); | ||
@@ -757,4 +758,4 @@ done(); | ||
expect(err).to.exist; | ||
expect(credentials).to.exist; | ||
expect(err).to.exist(); | ||
expect(credentials).to.exist(); | ||
done(); | ||
@@ -1152,7 +1153,7 @@ }); | ||
var auth = Browser.client.message('example.com', 8080, 'some message', { credentials: credentials }); | ||
expect(auth).to.exist; | ||
expect(auth).to.exist(); | ||
Hawk.server.authenticateMessage('example.com', 8080, 'some message', auth, credentialsFunc, {}, function (err, credentials) { | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -1169,3 +1170,3 @@ done(); | ||
var auth = Browser.client.message('example.com', 8080, 'some message', { credentials: credentials, nonce: 'abc123', timestamp: 1398536270957 }); | ||
expect(auth).to.exist; | ||
expect(auth).to.exist(); | ||
expect(auth.nonce).to.equal('abc123'); | ||
@@ -1182,3 +1183,3 @@ expect(auth.ts).to.equal(1398536270957); | ||
var auth = Browser.client.message(null, 8080, 'some message', { credentials: credentials }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -1193,3 +1194,3 @@ }); | ||
var auth = Browser.client.message(5, 8080, 'some message', { credentials: credentials }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -1204,3 +1205,3 @@ }); | ||
var auth = Browser.client.message('example.com', 0, 'some message', { credentials: credentials }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -1215,3 +1216,3 @@ }); | ||
var auth = Browser.client.message('example.com', 'a', 'some message', { credentials: credentials }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -1226,3 +1227,3 @@ }); | ||
var auth = Browser.client.message('example.com', 8080, undefined, { credentials: credentials }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -1237,3 +1238,3 @@ }); | ||
var auth = Browser.client.message('example.com', 8080, null, { credentials: credentials }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -1248,3 +1249,3 @@ }); | ||
var auth = Browser.client.message('example.com', 8080, 5, { credentials: credentials }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -1257,3 +1258,3 @@ }); | ||
var auth = Browser.client.message('example.com', 8080, 'some message', {}); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -1265,3 +1266,3 @@ }); | ||
var auth = Browser.client.message('example.com', 8080, 'some message'); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -1277,3 +1278,3 @@ }); | ||
var auth = Browser.client.message('example.com', 8080, 'some message', { credentials: creds }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -1290,3 +1291,3 @@ }); | ||
var auth = Browser.client.message('example.com', 8080, 'some message', { credentials: creds }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -1303,3 +1304,3 @@ }); | ||
var auth = Browser.client.message('example.com', 8080, 'some message', { credentials: creds }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -1388,6 +1389,6 @@ }); | ||
expect(Browser.utils.storage.getItem('hawk_ntp_offset')).to.not.exist; | ||
expect(Browser.utils.storage.getItem('hawk_ntp_offset')).to.not.exist(); | ||
Browser.utils.storage.setItem('test', '1'); | ||
Browser.utils.setStorage(new Browser.internals.LocalStorage()); | ||
expect(Browser.utils.storage.getItem('test')).to.not.exist; | ||
expect(Browser.utils.storage.getItem('test')).to.not.exist(); | ||
Browser.utils.storage.setItem('test', '2'); | ||
@@ -1394,0 +1395,0 @@ expect(Browser.utils.storage.getItem('test')).to.equal('2'); |
// Load modules | ||
var Url = require('url'); | ||
var Code = require('code'); | ||
var Hawk = require('../lib'); | ||
var Lab = require('lab'); | ||
var Hawk = require('../lib'); | ||
@@ -18,3 +19,3 @@ | ||
var it = lab.test; | ||
var expect = Lab.expect; | ||
var expect = Code.expect; | ||
@@ -321,3 +322,3 @@ | ||
var auth = Hawk.client.message('example.com', 80, 'I am the boodyman', { credentials: credentials, timestamp: 1353809207, nonce: 'abc123' }); | ||
expect(auth).to.exist; | ||
expect(auth).to.exist(); | ||
expect(auth.ts).to.equal(1353809207); | ||
@@ -337,3 +338,3 @@ expect(auth.nonce).to.equal('abc123'); | ||
var auth = Hawk.client.message(5, 80, 'I am the boodyman', { credentials: credentials, timestamp: 1353809207, nonce: 'abc123' }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -351,3 +352,3 @@ }); | ||
var auth = Hawk.client.message('example.com', '80', 'I am the boodyman', { credentials: credentials, timestamp: 1353809207, nonce: 'abc123' }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -365,3 +366,3 @@ }); | ||
var auth = Hawk.client.message('example.com', 0, 'I am the boodyman', { credentials: credentials, timestamp: 1353809207, nonce: 'abc123' }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -379,3 +380,3 @@ }); | ||
var auth = Hawk.client.message('example.com', 80, null, { credentials: credentials, timestamp: 1353809207, nonce: 'abc123' }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -393,3 +394,3 @@ }); | ||
var auth = Hawk.client.message('example.com', 80, undefined, { credentials: credentials, timestamp: 1353809207, nonce: 'abc123' }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -407,3 +408,3 @@ }); | ||
var auth = Hawk.client.message('example.com', 80, 5, { credentials: credentials, timestamp: 1353809207, nonce: 'abc123' }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -421,3 +422,3 @@ }); | ||
var auth = Hawk.client.message('example.com', 80, 'I am the boodyman'); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -434,3 +435,3 @@ }); | ||
var auth = Hawk.client.message('example.com', 80, 'I am the boodyman', { credentials: credentials, timestamp: 1353809207, nonce: 'abc123' }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -447,3 +448,3 @@ }); | ||
var auth = Hawk.client.message('example.com', 80, 'I am the boodyman', { credentials: credentials, timestamp: 1353809207, nonce: 'abc123' }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -450,0 +451,0 @@ }); |
// Load modules | ||
var Code = require('code'); | ||
var Hawk = require('../lib'); | ||
var Lab = require('lab'); | ||
var Hawk = require('../lib'); | ||
@@ -17,3 +18,3 @@ | ||
var it = lab.test; | ||
var expect = Lab.expect; | ||
var expect = Code.expect; | ||
@@ -20,0 +21,0 @@ |
// Load modules | ||
var Url = require('url'); | ||
var Code = require('code'); | ||
var Hawk = require('../lib'); | ||
var Lab = require('lab'); | ||
var Hawk = require('../lib'); | ||
@@ -18,3 +19,3 @@ | ||
var it = lab.test; | ||
var expect = Lab.expect; | ||
var expect = Code.expect; | ||
@@ -48,7 +49,7 @@ | ||
req.authorization = Hawk.client.header(Url.parse('http://example.com:8080/resource/4?filter=a'), req.method, { credentials: credentials, ext: 'some-app-data' }).field; | ||
expect(req.authorization).to.exist; | ||
expect(req.authorization).to.exist(); | ||
Hawk.server.authenticate(req, credentialsFunc, {}, function (err, credentials, artifacts) { | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -81,3 +82,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -94,3 +95,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
res.headers['server-authorization'] = Hawk.server.header(credentials, artifacts, { payload: 'some reply', contentType: 'text/plain', ext: 'response-specific' }); | ||
expect(res.headers['server-authorization']).to.exist; | ||
expect(res.headers['server-authorization']).to.exist(); | ||
@@ -123,3 +124,3 @@ expect(Hawk.client.authenticate(res, credentials, artifacts, { payload: 'some reply' })).to.equal(true); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -136,3 +137,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
res.headers['server-authorization'] = Hawk.server.header(credentials, artifacts, { payload: 'some reply', contentType: 'text/plain', ext: 'response-specific' }); | ||
expect(res.headers['server-authorization']).to.exist; | ||
expect(res.headers['server-authorization']).to.exist(); | ||
@@ -165,3 +166,3 @@ expect(Hawk.client.authenticate(res, credentials, artifacts, { payload: 'some reply' })).to.equal(true); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -178,3 +179,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
res.headers['server-authorization'] = Hawk.server.header(credentials, artifacts); | ||
expect(res.headers['server-authorization']).to.exist; | ||
expect(res.headers['server-authorization']).to.exist(); | ||
@@ -207,3 +208,3 @@ expect(Hawk.client.authenticate(res, credentials, artifacts)).to.equal(true); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -220,3 +221,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
res.headers['server-authorization'] = Hawk.server.header(credentials, artifacts); | ||
expect(res.headers['server-authorization']).to.exist; | ||
expect(res.headers['server-authorization']).to.exist(); | ||
@@ -243,3 +244,3 @@ expect(Hawk.client.authenticate(res, credentials, artifacts, { payload: 'some reply' })).to.equal(false); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -266,7 +267,7 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
expect(artifacts.ext).to.equal('some-app-data'); | ||
expect(Hawk.server.authenticatePayload('hola!', credentials, artifacts)).to.be.true; | ||
expect(Hawk.server.authenticatePayload('hello!', credentials, artifacts)).to.be.false; | ||
expect(Hawk.server.authenticatePayload('hola!', credentials, artifacts)).to.be.true(); | ||
expect(Hawk.server.authenticatePayload('hello!', credentials, artifacts)).to.be.false(); | ||
done(); | ||
@@ -291,3 +292,3 @@ }); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -314,3 +315,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -338,3 +339,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -363,3 +364,3 @@ expect(artifacts.ext).to.equal('some-app-data'); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Bad payload hash'); | ||
@@ -387,4 +388,4 @@ done(); | ||
expect(err).to.exist; | ||
expect(credentials).to.exist; | ||
expect(err).to.exist(); | ||
expect(credentials).to.exist(); | ||
done(); | ||
@@ -391,0 +392,0 @@ }); |
// Load modules | ||
var Url = require('url'); | ||
var Code = require('code'); | ||
var Hawk = require('../lib'); | ||
var Hoek = require('hoek'); | ||
var Lab = require('lab'); | ||
var Hoek = require('hoek'); | ||
var Hawk = require('../lib'); | ||
@@ -19,3 +20,3 @@ | ||
var it = lab.test; | ||
var expect = Lab.expect; | ||
var expect = Code.expect; | ||
@@ -42,7 +43,7 @@ | ||
var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials }); | ||
expect(auth).to.exist; | ||
expect(auth).to.exist(); | ||
Hawk.server.authenticateMessage('example.com', 8080, 'some message', auth, credentialsFunc, {}, function (err, credentials) { | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -59,7 +60,7 @@ done(); | ||
var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials }); | ||
expect(auth).to.exist; | ||
expect(auth).to.exist(); | ||
Hawk.server.authenticateMessage('example1.com', 8080, 'some message', auth, credentialsFunc, {}, function (err, credentials) { | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Bad mac'); | ||
@@ -76,7 +77,7 @@ done(); | ||
var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials }); | ||
expect(auth).to.exist; | ||
expect(auth).to.exist(); | ||
Hawk.server.authenticateMessage('example.com', 8080, 'some message', auth, credentialsFunc, { localtimeOffsetMsec: 100000 }, function (err, credentials) { | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Stale timestamp'); | ||
@@ -93,7 +94,7 @@ done(); | ||
var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials, localtimeOffsetMsec: 100000 }); | ||
expect(auth).to.exist; | ||
expect(auth).to.exist(); | ||
Hawk.server.authenticateMessage('example.com', 8080, 'some message', auth, credentialsFunc, { timestampSkewSec: 500 }, function (err, credentials) { | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
done(); | ||
@@ -109,3 +110,3 @@ }); | ||
var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials }); | ||
expect(auth).to.exist; | ||
expect(auth).to.exist(); | ||
delete auth.id; | ||
@@ -115,3 +116,3 @@ | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Invalid authorization'); | ||
@@ -128,7 +129,7 @@ done(); | ||
var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials }); | ||
expect(auth).to.exist; | ||
expect(auth).to.exist(); | ||
Hawk.server.authenticateMessage('example.com', 8080, 'some message1', auth, credentialsFunc, {}, function (err, credentials) { | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Bad message hash'); | ||
@@ -145,7 +146,7 @@ done(); | ||
var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials }); | ||
expect(auth).to.exist; | ||
expect(auth).to.exist(); | ||
Hawk.server.authenticateMessage('example.com', 8080, 'some message', auth, credentialsFunc, { nonceFunc: function (nonce, ts, callback) { callback (new Error('kaboom')); } }, function (err, credentials) { | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Invalid nonce'); | ||
@@ -162,3 +163,3 @@ done(); | ||
var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials }); | ||
expect(auth).to.exist; | ||
expect(auth).to.exist(); | ||
@@ -172,3 +173,3 @@ var errFunc = function (id, callback) { | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('kablooey'); | ||
@@ -185,3 +186,3 @@ done(); | ||
var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials }); | ||
expect(auth).to.exist; | ||
expect(auth).to.exist(); | ||
@@ -195,3 +196,3 @@ var errFunc = function (id, callback) { | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Unknown credentials'); | ||
@@ -208,3 +209,3 @@ done(); | ||
var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials }); | ||
expect(auth).to.exist; | ||
expect(auth).to.exist(); | ||
@@ -218,3 +219,3 @@ var errFunc = function (id, callback) { | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Invalid credentials'); | ||
@@ -231,3 +232,3 @@ done(); | ||
var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: credentials }); | ||
expect(auth).to.exist; | ||
expect(auth).to.exist(); | ||
@@ -241,3 +242,3 @@ var errFunc = function (id, callback) { | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Unknown algorithm'); | ||
@@ -254,3 +255,3 @@ done(); | ||
var auth = Hawk.client.message(null, 8080, 'some message', { credentials: credentials }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -263,3 +264,3 @@ }); | ||
var auth = Hawk.client.message('example.com', 8080, 'some message', {}); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -275,3 +276,3 @@ }); | ||
var auth = Hawk.client.message('example.com', 8080, 'some message', { credentials: creds }); | ||
expect(auth).to.not.exist; | ||
expect(auth).to.not.exist(); | ||
done(); | ||
@@ -278,0 +279,0 @@ }); |
// Load modules | ||
var Code = require('code'); | ||
var Hawk = require('../lib'); | ||
var Hoek = require('hoek'); | ||
var Lab = require('lab'); | ||
var Hoek = require('hoek'); | ||
var Hawk = require('../lib'); | ||
@@ -18,3 +19,3 @@ | ||
var it = lab.test; | ||
var expect = Lab.expect; | ||
var expect = Code.expect; | ||
@@ -21,0 +22,0 @@ |
// Load modules | ||
var Url = require('url'); | ||
var Code = require('code'); | ||
var Hawk = require('../lib'); | ||
var Lab = require('lab'); | ||
var Hawk = require('../lib'); | ||
@@ -18,3 +19,3 @@ | ||
var it = lab.test; | ||
var expect = Lab.expect; | ||
var expect = Code.expect; | ||
@@ -52,3 +53,3 @@ | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -71,3 +72,3 @@ done(); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -91,3 +92,3 @@ done(); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -111,3 +112,3 @@ done(); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -130,3 +131,3 @@ done(); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -149,3 +150,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Missing required payload hash'); | ||
@@ -168,3 +169,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Stale timestamp'); | ||
@@ -213,3 +214,3 @@ var header = err.output.headers['WWW-Authenticate']; | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -219,3 +220,3 @@ | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Invalid nonce'); | ||
@@ -239,4 +240,4 @@ done(); | ||
expect(err).to.exist; | ||
expect(err.output.payload.message).to.not.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.not.exist(); | ||
done(); | ||
@@ -258,3 +259,3 @@ }); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Invalid header syntax'); | ||
@@ -276,3 +277,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.isMissing).to.equal(true); | ||
@@ -295,3 +296,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Invalid Host header'); | ||
@@ -314,3 +315,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Missing attributes'); | ||
@@ -333,3 +334,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Missing attributes'); | ||
@@ -352,3 +353,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Missing attributes'); | ||
@@ -371,3 +372,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Missing attributes'); | ||
@@ -390,3 +391,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Unknown attribute: x'); | ||
@@ -409,3 +410,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Bad header format'); | ||
@@ -428,3 +429,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Bad attribute value: id'); | ||
@@ -447,3 +448,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Bad attribute value: id'); | ||
@@ -466,3 +467,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Duplicate attribute: id'); | ||
@@ -485,3 +486,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Invalid header syntax'); | ||
@@ -505,3 +506,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Invalid Host header'); | ||
@@ -525,3 +526,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Invalid Host header'); | ||
@@ -549,3 +550,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Unknown user'); | ||
@@ -573,3 +574,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Unknown user'); | ||
@@ -598,3 +599,3 @@ expect(credentials.some).to.equal('value'); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Unknown credentials'); | ||
@@ -627,3 +628,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Invalid credentials'); | ||
@@ -657,3 +658,3 @@ expect(err.output.payload.message).to.equal('An internal server error occurred'); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Invalid credentials'); | ||
@@ -688,3 +689,3 @@ expect(err.output.payload.message).to.equal('An internal server error occurred'); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Unknown algorithm'); | ||
@@ -719,3 +720,3 @@ expect(err.output.payload.message).to.equal('An internal server error occurred'); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Bad mac'); | ||
@@ -951,3 +952,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Invalid authorization'); | ||
@@ -968,3 +969,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Invalid authorization'); | ||
@@ -985,3 +986,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Invalid authorization'); | ||
@@ -1001,3 +1002,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('something'); | ||
@@ -1004,0 +1005,0 @@ expect(credentials.some).to.equal('value'); |
@@ -5,5 +5,6 @@ // Load modules | ||
var Url = require('url'); | ||
var Code = require('code'); | ||
var Hawk = require('../lib'); | ||
var Hoek = require('hoek'); | ||
var Lab = require('lab'); | ||
var Hawk = require('../lib'); | ||
@@ -21,3 +22,3 @@ | ||
var it = lab.test; | ||
var expect = Lab.expect; | ||
var expect = Code.expect; | ||
@@ -57,3 +58,3 @@ | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -82,3 +83,3 @@ expect(attributes.ext).to.equal('some-app-data'); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -101,3 +102,3 @@ done(); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -120,3 +121,3 @@ expect(attributes.ext).to.equal('some-app-data'); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -139,3 +140,3 @@ expect(attributes.ext).to.equal('some-app-data'); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(credentials.user).to.equal('steve'); | ||
@@ -159,3 +160,3 @@ expect(attributes.ext).to.equal('some-app-data'); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Multiple authentications'); | ||
@@ -195,3 +196,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Invalid method'); | ||
@@ -215,3 +216,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Invalid Host header'); | ||
@@ -233,5 +234,5 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Empty bewit'); | ||
expect(err.isMissing).to.not.exist; | ||
expect(err.isMissing).to.not.exist(); | ||
done(); | ||
@@ -252,5 +253,5 @@ }); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Invalid bewit encoding'); | ||
expect(err.isMissing).to.not.exist; | ||
expect(err.isMissing).to.not.exist(); | ||
done(); | ||
@@ -271,4 +272,4 @@ }); | ||
expect(err).to.exist; | ||
expect(err.output.payload.message).to.not.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.not.exist(); | ||
expect(err.isMissing).to.equal(true); | ||
@@ -290,3 +291,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Invalid bewit structure'); | ||
@@ -308,3 +309,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Missing bewit attributes'); | ||
@@ -326,3 +327,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Missing bewit attributes'); | ||
@@ -344,3 +345,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Access expired'); | ||
@@ -362,3 +363,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Boom'); | ||
@@ -380,3 +381,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Boom'); | ||
@@ -399,3 +400,3 @@ expect(credentials.some).to.equal('value'); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Unknown credentials'); | ||
@@ -417,3 +418,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Invalid credentials'); | ||
@@ -435,3 +436,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.message).to.equal('Unknown algorithm'); | ||
@@ -453,3 +454,3 @@ done(); | ||
expect(err).to.exist; | ||
expect(err).to.exist(); | ||
expect(err.output.payload.message).to.equal('Bad mac'); | ||
@@ -456,0 +457,0 @@ done(); |
// Load modules | ||
var Code = require('code'); | ||
var Hawk = require('../lib'); | ||
var Lab = require('lab'); | ||
var Hawk = require('../lib'); | ||
var Package = require('../package.json'); | ||
@@ -18,3 +19,3 @@ | ||
var it = lab.test; | ||
var expect = Lab.expect; | ||
var expect = Code.expect; | ||
@@ -21,0 +22,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
347232
27
4756
636
2