Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}, pick(authSettings, ...INCLUDE_KEYS), providerSettings, omit(options, ...EXCLUDE_KEYS));
// Set callback defaults based on provided path
oauth1Settings.callbackPath = oauth1Settings.callbackPath || `${oauth1Settings.path}/callback`;
oauth1Settings.callbackURL = oauth1Settings.callbackURL || makeUrl(oauth1Settings.callbackPath, app);
if (!oauth1Settings.consumerKey) {
throw new Error(`You must provide a 'consumerKey' in your authentication configuration or pass one explicitly`);
}
if (!oauth1Settings.consumerSecret) {
throw new Error(`You must provide a 'consumerSecret' in your authentication configuration or pass one explicitly`);
}
const Verifier = options.Verifier || DefaultVerifier;
const formatter = options.formatter || rest.formatter;
const handler = options.handler || defaultHandler(oauth1Settings);
const errorHandler = defaultErrorHandler(oauth1Settings);
// register OAuth middleware
debug(`Registering '${name}' Express OAuth middleware`);
app.get(oauth1Settings.path, auth.express.authenticate(name, oauth1Settings));
app.get(
oauth1Settings.callbackPath,
// NOTE (EK): We register failure redirect here so that we can
// retain the natural express middleware redirect ability like
// you would have with vanilla passport.
auth.express.authenticate(name, oauth1Settings),
handler,
errorHandler,
auth.express.emitEvents(authSettings, app),
auth.express.setCookie(authSettings),