Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.googleCallback = getLoginCallbackFunction('google');
}
var opts = {}
opts.jwtFromRequest = ExtractJwt.fromAuthHeader();
// secretOrKey is not really important since we will set it dynamically according
// to the "Cocorico-App-Id" HTTP header. But it still has to be != false.
opts.secretOrKey = 'secret';
// JwtStrategy reads the JWT secret from the option object above. But
// we need the secret to be the one set for the corresponding App.
// Thus, we override the JwtStrategy.prototype.authenticate method in order to set
// the secret according to the App found using the "Cocorico-App-Id" header.
var authenticate = JwtStrategy.prototype.authenticate;
JwtStrategy.prototype.authenticate = function(req, options) {
var token = this._jwtFromRequest(req);
if (!token) {
return this.fail();
}
var appId = req.headers['cocorico-app-id'];
if (!appId) {
return this.fail(new Error('Missing Cocorico-App-Id header'));
}
return App.model.findById(appId).exec((err, app) => {
if (err) {
return this.fail(err);
}
exports.googleLogin = getLoginFunction('google', { scope: [ 'profile' ] });
exports.googleCallback = getLoginCallbackFunction('google');
}
var opts = {}
opts.jwtFromRequest = ExtractJwt.fromAuthHeader();
// secretOrKey is not really important since we will set it dynamically according
// to the "Cocorico-App-Id" HTTP header. But it still has to be != false.
opts.secretOrKey = 'secret';
// JwtStrategy reads the JWT secret from the option object above. But
// we need the secret to be the one set for the corresponding App.
// Thus, we override the JwtStrategy.prototype.authenticate method in order to set
// the secret according to the App found using the "Cocorico-App-Id" header.
var authenticate = JwtStrategy.prototype.authenticate;
JwtStrategy.prototype.authenticate = function(req, options) {
var token = this._jwtFromRequest(req);
if (!token) {
return this.fail();
}
var appId = req.headers['cocorico-app-id'];
if (!appId) {
return this.fail(new Error('Missing Cocorico-App-Id header'));
}
return App.model.findById(appId).exec((err, app) => {
if (err) {
return this.fail(err);
}