护照 Saml 循环
Passport Saml Loop
我正在尝试在 nodejs/angularjs 项目中使用 Passport-Saml.js 进行 ADFS 标识。
- 当我连接到我的网站时,我被正确地重定向到我的 ADFS 门户。
- ADFS 门户,身份验证后正确重定向到回调。
- 然后回调循环。
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){ 处停止工作,因为可以在控制台中看到 "before" 输出消息,但 "good" 如屏幕截图所示。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;
我怀疑我的设置可能不正确,但是否有任何详细的 passport-Saml 日志以缩小我的故障排除范围。
可能是这个问题:
Check this bug
只需添加正文解析器
var bodyParser = require('body-parser');
...
app.use(bodyParser.urlencoded({extended: true}));
它对我有用。也许它可以帮助别人...
感谢 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}));
我正在尝试在 nodejs/angularjs 项目中使用 Passport-Saml.js 进行 ADFS 标识。
- 当我连接到我的网站时,我被正确地重定向到我的 ADFS 门户。
- ADFS 门户,身份验证后正确重定向到回调。
- 然后回调循环。
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){ 处停止工作,因为可以在控制台中看到 "before" 输出消息,但 "good" 如屏幕截图所示。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;
我怀疑我的设置可能不正确,但是否有任何详细的 passport-Saml 日志以缩小我的故障排除范围。
可能是这个问题: Check this bug
只需添加正文解析器
var bodyParser = require('body-parser');
...
app.use(bodyParser.urlencoded({extended: true}));
它对我有用。也许它可以帮助别人...
感谢 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}));