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
oauth2Settings.callbackPath = oauth2Settings.callbackPath || `${oauth2Settings.path}/callback`;
oauth2Settings.callbackURL = oauth2Settings.callbackURL || makeUrl(oauth2Settings.callbackPath, app);
if (!oauth2Settings.clientID) {
throw new Error(`You must provide a 'clientID' in your authentication configuration or pass one explicitly`);
}
if (!oauth2Settings.clientSecret) {
throw new Error(`You must provide a 'clientSecret' in your authentication configuration or pass one explicitly`);
}
const Verifier = options.Verifier || DefaultVerifier;
const formatter = options.formatter || rest.formatter;
const handler = options.handler || defaultHandler(oauth2Settings);
const errorHandler = typeof options.errorHandler === 'function' ? options.errorHandler(oauth2Settings) : defaultErrorHandler(oauth2Settings);
// register OAuth middleware
debug(`Registering '${name}' Express OAuth middleware`);
app.get(oauth2Settings.path, auth.express.authenticate(name, omit(oauth2Settings, 'state')));
app.get(
oauth2Settings.callbackPath,
_callbackAuthenticator(authSettings),
auth.express.authenticate(name, omit(oauth2Settings, 'state')),
handler,
errorHandler,
auth.express.emitEvents(authSettings, app),
auth.express.setCookie(authSettings),
auth.express.successRedirect(),
auth.express.failureRedirect(authSettings),