I’m trying to integrate passport.js which uses the node connect
middleware. The connect
library is what Webapp exposes in Webapp.connectedHandlers ( https://docs.meteor.com/packages/webapp.html ). Most passport examples use express, none with meteor.
The closest thing I could find is: http://stackoverflow.com/questions/11006318/using-passportjs-with-connect-for-nodejs-to-authenticate-facebook-users
From reading passport, using a unique token strategy should be simple. https://github.com/Lughino/passport-unique-token
const passport = require('passport')
const UniqueTokenStrategy = require('passport-unique-token').Strategy
const debug = require('debug')('wireline:passport')
WebApp.connectHandlers.use(passport.initialize())
passport.use(new UniqueTokenStrategy(
function (token, done) {
console.log('token', token) // no logs appearing
if ( token ){
return done(null, 'ok');
} else {
done('err', null)
}
}
));
// passport.authenticate generates the callback function 'connect' would need
callbackFunc = passport.authenticate('token')
WebApp.connectHandlers.use('/passportTestRoute', callbackFunc)
It doesn’t throw any exception. On requesting the route, it doesn’t seem to run the function, since the consoe.log check isn’t printed. All I get is a bad request
as the response in the browser, and no meaningful logs.
Any thoughts?