【问题标题】:Passport Saml Loop护照 Saml Loop
【发布时间】:2016-04-10 12:24:05
【问题描述】:

我正在尝试在 nodejs/angularjs 项目中使用 Passport-Saml.js 进行 ADFS 识别。

  1. 当我连接到我的网站时,我被正确重定向到我的 ADFS 门户。
  2. ADFS 门户,在身份验证后正确重定向到回调。
  3. 然后是回调循环。

Chrome console when it's looping

我的路线(server.js):

app.post('/login/callback',
 function (req, res, next) {
  console.log('before');
  passport.authenticate('saml', function (err, user, info){
    console.log('good');

})(req, res, next);

});

我认为它在 passport.authenticate('saml',function (err,user, info){ 停止工作,因为可以在控制台中看到“之前”输出消息,但也不能在屏幕截图中看到“好”。 The console

还有我的护照配置(/config/passport.js):

var
 fs = require('fs')
 , passport = require('passport')
 , SamlStrategy = require('passport-saml').Strategy
;

passport.serializeUser(function (user, done) {
 done(null, user);
});
passport.deserializeUser(function (user, done) {
 done(null, user);
});

passport.use(new SamlStrategy(
{
  entryPoint: 'https://logon.XXX.com/adfs/ls/',
  issuer: 'urn:backpack-test',
  callbackUrl: ' https://backpack-test.XXX.com/login/callback',
  cert: 'MIIC6D...,
  authnContext:         'http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/password',
  //acceptedClockSkewMs: -1,
  identifierFormat: null,
  //signatureAlgorithm: 'sha256'
},
function (profile, done) {
 return done(null,
  {
        upn: profile['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn'],
        // e.g. if you added a Group claim
        group: profile['http://schemas.xmlsoap.org/claims/Group']
    });
    }
    ));

module.exports = passport;

我怀疑我的设置可能不正确,但是否有任何护照 Saml 的详细日志以缩小我的故障排除范围。

【问题讨论】:

  • 你能找出问题所在吗?

标签: node.js passport.js mean-stack adfs


【解决方案1】:

也许是这个问题: Check this bug

只需添加正文解析器

var bodyParser = require('body-parser');
...
app.use(bodyParser.urlencoded({extended: true}));

它对我有用。也许它可以帮助别人......

【讨论】:

  • 有同样的循环问题。添加 bodyParser 解决了我的问题。
【解决方案2】:

感谢 perseus,我只添加了一个注释。我正在使用:

var bodyParser = require('body-parser');
app.use(bodyParser.json({limit: '5mb'}));

我认为这就足够了,但事实并非如此,因为正文解析器忽略了 urlencoded 请求。所以我必须同时指定:

var bodyParser = require('body-parser');
app.use(bodyParser.json({limit: '5mb'}));
app.use(bodyParser.urlencoded({extended: true}));

【讨论】:

    猜你喜欢
    • 2014-08-16
    • 2017-02-03
    • 1970-01-01
    • 2018-07-11
    • 2021-06-20
    • 1970-01-01
    • 2018-01-11
    • 2019-03-03
    • 1970-01-01
    相关资源
    最近更新 更多