jaredhanson / passport-http

HTTP Basic and Digest authentication strategies for Passport and Node.js.

Home Page:https://www.passportjs.org/packages/passport-http/?utm_source=github&utm_medium=referral&utm_campaign=passport-http&utm_content=about

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strategy naming for basic auth

korialis opened this issue · comments

Maybe I'm missing something: I'm trying to implement a service using different 'layers of authentication', to do so I'd like to specify 3 different BasicStrategy. As I understood from an old issue (jaredhanson/passport#50) this is possible for LocalStrategy, but I've been unsuccessfull to do the same for BasicStrategy, since the constructor doesn't allow custom names.

Is there any reason for this asymmetric behaviour between the strategies?

I even tried to instantiate the strategy, then assign a custom name and use it like this:

var adminStrat = new BasicStrategy(.....);

passport.use('admin-strat', adminStrat);
exports.isAdmin = passport.authenticate('admin-strat', { session: false });

My fault, had a misleading bug not relating passport, sorry for the useless issue...closing it!