【问题标题】:Integrating passport.js & Meteor集成 passport.js 和 Meteor
【发布时间】:2013-06-11 09:50:37
【问题描述】:

我正在尝试在我的 Meteor 项目中实现 passport.js,但我有点卡住通过护照发送用户信息。

首先,我正在构建一个在组织方面使用 LDAP 的身份验证系统。 y 购买了 Shibboleth 的身份提供程序 http://shibboleth.net/products/identity-provider.html 并希望使用 passport-saml 作为驻留在 Web 应用程序中的身份验证框架。我遵循了这个 git 教程 https://github.com/bergie/passport-saml 以及官方的 passport.js 教程,并且我已经在 Meteor 的服务器端实现了 passport.js 中的方法。

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);
    });
  });

});

我现在的问题是如何获得护照以发送用户信息。是通过passport.use中的函数传递配置文件对象来完成的吗?

非常感谢,我不确定我应该显示多少代码,请给我留言,我会改进这篇文章!

【问题讨论】:

    标签: meteor meteorite passport.js


    【解决方案1】:

    这是在 Meteor 在 6.4 中更新对 oAuth 的支持之前提出的,我假设用户已经解决了这个问题。对于我们这些正在搜索 oAuth + Meteor 的人来说,它现在集成得更好了。

    无需弄乱passport.js

    在此处查看博文:https://www.meteor.com/blog/2013/06/10/meteor-064-new-oauth-packages-and-recommended-updates

    基本上你现在可以这样做了:

    $ meteor add accounts-twitter
    $ meteor add accounts-facebook
    

    等等

    【讨论】:

      【解决方案2】:

      我刚刚发布了一个陨石包,它允许基于 saml 登录现有的密码支持帐户 - 请在 https://atmosphere.meteor.com/package/accounts-saml 上查看 - 包仍然有点粗糙,因此可能需要一些调整才能与各种 saml 提供商合作

      【讨论】:

        猜你喜欢
        • 2012-12-13
        • 2018-09-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-05-04
        • 2012-04-25
        • 1970-01-01
        • 2015-09-27
        相关资源
        最近更新 更多