Integrating passport.js & Meteor
Asked Answered
H

2

6

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!

Harebrained answered 14/6, 2013 at 17:2 Comment(0)
R
1

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.

Rheingold answered 25/10, 2013 at 18:37 Comment(0)
D
0

i just released a meteorite package which allows for saml based logins for existing password backed accounts - check it out at https://atmosphere.meteor.com/package/accounts-saml - package is still a bit rough, so might need some adjustments to work with various saml providers

Delight answered 27/11, 2013 at 18:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.