Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_.each(strategies, function(strategy, strategyName) {
// Get the name we used to register this strategy with passport. This is a combination of the tenant and strategy name
var passportStrategyName = AuthenticationUtil.getStrategyId(tenant, strategyName);
// Disable the passport strategy if we registered it previously.
if (passport._strategy(passportStrategyName)) {
passport.unuse(passportStrategyName);
}
// If the tenant wants the strategy enabled, we enable it. We also create a new instance of the passport strategy so that
// configuration updates to the strategy are taken into account
if (strategy.shouldBeEnabled(tenant.alias)) {
passport.use(passportStrategyName, strategy.getPassportStrategy(tenant));
log().debug({'tenant': tenant.alias, 'strategy': strategyName, 'passportStrategyName': passportStrategyName}, 'Enabling strategy');
}
});
_remove_value: function( t, strategy ) {
var position = this._a_index_of( strategy )
, strategy_name = strategy.name
;
de&&ug( this._get_name( '_remove_value' ), { strategy_name: strategy_name, position: position } );
if ( position != -1 ) {
// Unuse passport strategy, using undocumented passport.unuse() source code:
// https://github.com/jaredhanson/passport/blob/master/lib/authenticator.js#L79
passport.unuse( strategy_name );
Super._remove_value.call( this, t, get_emitted_strategy( strategy ) );
} else {
t.emit_nothing();
}
} // _remove_value()
}; // passport_strategies() prototype
resetSamlStrategy() {
debug('SamlStrategy: reset');
passport.unuse('saml');
this.isSamlStrategySetup = false;
}
resetGitHubStrategy() {
debug('GitHubStrategy: reset');
passport.unuse('github');
this.isGitHubStrategySetup = false;
}
resetGoogleStrategy() {
debug('GoogleStrategy: reset');
passport.unuse('google');
this.isGoogleStrategySetup = false;
}
resetLdapStrategy() {
debug('LdapStrategy: reset');
passport.unuse('ldapauth');
this.isLdapStrategySetup = false;
}
unuse(name) {
passport.unuse(name);
delete this.options[name];
}
}
resetTwitterStrategy() {
debug('TwitterStrategy: reset');
passport.unuse('twitter');
this.isTwitterStrategySetup = false;
}
resetLocalStrategy() {
debug('LocalStrategy: reset');
passport.unuse('local');
this.isLocalStrategySetup = false;
}
resetBasicStrategy() {
debug('BasicStrategy: reset');
passport.unuse('basic');
this.isBasicStrategySetup = false;
}