You can configure several of these strategies in the passport, even one type. Below I can have two instances of myStrategy with different configurations, but in a different way,
For instance:
passport.use('someStrategy', new myStrategy(options)) passport.use('anotherStrategy', new myStrategy(differentOptions));
Then, after authentication, you can specify which strategy to use:
passport.authenticate('someStrategy', ...);
Using the foregoing, you can configure several strategies and, based on a conditional decision, decide which strategy to use:
if (condition){ passport.authenticate('someStrategy', ...); } else{ passport.authenticate('anotherStrategy', ...); }
Or:
let strategyToUse = determineStrategy();
Removing a strategy from the middleware stack is a bit more complicated, and there is no built-in function for this, I don't think. This may require manual splicing of the strategy from the stack. This question may help you remove middleware from the stack; his goal of express communication should also apply to a passport to some extent.
Mitch source share