Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Strategy.prototype.authenticate = function(req) {
//express change req.url when mounting with app.use
//this creates a new request object with url = originalUrl
req = xtend({}, req, { url: req.originalUrl || req.url });
if(this.bewit){
hawk.uri.authenticate(req, this.verify, {}, function (err, credentials, ext) {
if (err && err.isMissing) return this.fail('Missing authentication tokens');
if (err && err.message === 'Missing credentials') return this.fail('Invalid authentication tokens');
if (err) return this.error(new Error(err.message)); // Return hawk error
this.success(credentials.user, ext);
}.bind(this));
}else{
hawk.server.authenticate(req, this.verify, {}, function (err, credentials, ext) {
if (err && err.isMissing) return this.fail('Missing authentication tokens');
if (err && err.message === 'Missing credentials') return this.fail('Invalid authentication tokens');
if (err && err.message) return this.error(new Error(err.message)); // Return hawk error
this.success(credentials.user, ext);
}.bind(this));
}
};
it('should call done with false when the id doesnt exist', function(testDone) {
var bewit = Hawk.uri.getBewit('http://example.com:8080/foobar', {
credentials: {
id: '321321',
key: 'dsa',
algorithm: 'sha256'
},
ttlSec: 60 * 5
});
var req = {
headers: {
host: 'example.com:8080'
},
method: 'GET',
url: '/resource/4?filter=a&bewit=' + bewit
};
function Bewit(url) {
if( credentials ) {
var bewit = Hawk.uri.getBewit(url, { credentials: credentials, ttlSec: duration, ext: user.email })
url += "?bewit="+bewit
}
return url;
}
var source = req.gettext("sources.l8")
function Bewit(url) {
if( credentials ) {
var bewit = Hawk.uri.getBewit(url, { credentials: credentials, ttlSec: duration, ext: user.email })
url += "?bewit="+bewit
}
return url;
}
function Bewit(url) {
if( credentials ) {
var bewit = Hawk.uri.getBewit(url, { credentials: credentials, ttlSec: duration, ext: user.email })
url += "?bewit="+bewit
}
return url;
}
function Bewit(url) {
var bewit = Hawk.uri.getBewit(url, { credentials: credentials, ttlSec: duration, ext: user.email })
url += "?bewit="+bewit
return url;
}
function Bewit(url) {
var bewit = Hawk.uri.getBewit(url, { credentials: credentials, ttlSec: duration, ext: user.email })
url += "?bewit="+bewit
return url;
}
function Bewit(url) {
if( credentials ) {
var bewit = Hawk.uri.getBewit(url, { credentials: credentials, ttlSec: duration, ext: user.email })
url += "?bewit="+bewit
}
return url;
}
var source = req.gettext("sources.dfo")
function Bewit(url) {
if( credentials ) {
var bewit = Hawk.uri.getBewit(url, { credentials: credentials, ttlSec: duration, ext: user.email })
url += "?bewit="+bewit
}
return url;
}
function Bewit(url) {
if( credentials ) {
var bewit = Hawk.uri.getBewit(url, { credentials: credentials, ttlSec: duration, ext: user.email })
url += "?bewit="+bewit
}
return url;
}