我正在尝试使用WSO2身份服务器为Node.js应用程序实现单点登录服务。我是SSO领域的新手。
我已在本地部署了WSO2身份服务器。
我正在使用这个简单的节点应用程序作为服务提供者。
var express = require("express");
var passport = require("passport");
var SamlStrategy = require('passport-saml').Strategy;
var bodyParser = require("body-parser");
var session = require("express-session");
var app = express();
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(session({ secret: 'this shit hits'}));
app.use(passport.initialize());
app.use(passport.session());
var redirectLogin = function (req,res,next) {
if (!req.isAuthenticated()) {
res.redirect("/myapp/login");
}
next();
}
passport.serializeUser(function(user, done) {
done(null, user);
});
passport.deserializeUser(function(user, done) {
done(null, user);
});
passport.use(new SamlStrategy({
entryPoint: 'https://localhost:9443/samlsso',
issuer: 'MyAppExpress'
},
function(profile, done) {
var myUser = {
email : profile.nameID
}
done(null, myUser);
}));
app.get('/myapp/login',
passport.authenticate('saml', {
successRedirect: "/myapp",
failureRedirect: "/myapp/login",
}));
app.post('/myapp/saml', passport.authenticate('saml', {
failureRedirect: "/myapp/login",
failureFlash: true
})
,
function(req, res) {
res.redirect("/myapp");
}
);
app.get("/myapp",redirectLogin, function(req, res) {
res.send("you're authenticated !!!! "+ JSON.stringify(req.user));
});
app.listen(process.env.PORT || 1234);
我遵循了此链接上给出的指导原则。 SAML Authentication with WSO2 / LDAP / PASSPORT / EXPRESS
目前,我面临以下问题:
问题:
答案 0 :(得分:0)
问题是您在身份服务器中注册的Assertion使用者URL与服务提供者中使用的URL不匹配。
在您的服务提供商方:http://localhost:1234/saml/consume
在您的Identity Server配置中:http://localhost:8080/myapp/saml
在两次出现中使用相同的Assertion使用者URL
希望这有帮助。
答案 1 :(得分:0)
这个特殊的超链接是相似的,该示例确实适用于wso25.9.0(但显然仅在运行wso2is的同一台计算机上)。
https://medium.com/@athiththan11/saml-sso-with-passport-1690d2c38921