I am trying to implement passport.js in my Meteor project and I am kind of stuck sending user information via passport.
Firstup, I am building an authentication system that uses LDAP on the organization's side. The y have bought Shibboleth's Identity Provider, http://shibboleth.net/products/identity-provider.html and wants to use passport-saml as an authenticating framework residing the web app. I have followed this git tutorial, https://github.com/bergie/passport-saml , as well as the official passport.js tutorial and I have implemented the methods in passport.js in the server side of Meteor.
Meteor.startup(function () {
var require = Npm.require;
passport = require('passport');
var SamlStrategy = require('passport-saml').Strategy;
passport.use(new SamlStrategy(
{
path: '/login/callback',
entryPoint: 'https://openidp.feide.no/simplesaml/saml2/idp/SSOService.php',
issuer: 'passport-saml'
},
function(profile, done) {
findByEmail(profile.email, function(err, user) {
if (err) {
return done(err);
}
return done(null, user);
});
}
));
Meteor.Router.add('/login/callback', 'POST', function(req, res){
passport.authenticate('saml', { failureRedirect: '/', failureFlash: true });
res.redirect('/');
});
Meteor.Router.add('/login', 'POST', function(req, res){
passport.authenticate('saml', { failureRedirect: '/', failureFlash: true });
res.redirect('/');
});
var app = __meteor_bootstrap__.app;
app.use(passport.initialize());
app.use(passport.session());
passport.serializeUser(function(user, done) {
done(null, user.id);
});
passport.deserializeUser(function(id, done) {
User.findById(id, function(err, user) {
done(err, user);
});
});
});
My question now is how do i get passport to send the user information over. Is it done via passing a profile object via the function in passport.use?
Thanks so much and I am unsure of how much codes i should show, just drop me a comment and i will improve this post!
This was asked before Meteor updated support for oAuth in 6.4 and I assume that the user has figured this out. For those of us searching for oAuth + Meteor now it's integrated better now.
No need to mess with passport.js
See the blog post here: https://www.meteor.com/blog/2013/06/10/meteor-064-new-oauth-packages-and-recommended-updates
Essentially you can now do this:
$ meteor add accounts-twitter
$ meteor add accounts-facebook
etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With