关于如何解决看似简单的任务,我一直在摸不着头脑约2天,但它开始让我发疯.
我有一个应用程序,用户将使用SAML 2.0进行身份验证.我为前端设置了一个反应应用程序,并且认为我将使用JWT来确保前端和后端之间的rest-api通信.
当用户登录时,流程如下:
接下来我该怎么办?问题是,当从身份提供者回调时,用户不在react-application中,因此我已经丢失了应用程序中的所有状态,因此我回复的任何内容都将被发送到浏览器.
有什么办法可以强制浏览器给我一个identityprovider回拨的SamlResponse吗?然后我可以将它作为来自react-application的http请求发送到服务器.
我使用passport-saml在节点api中实现了ADFS SSO.登录有效但当我不放弃任何凭据并提交登录表单时,ADFS服务器会返回以下错误:
"SAML提供程序返回响应程序错误:未指定"
当我尝试再次登录后,ADFS直接返回到回调URL并再次弹出错误.
passport.use('saml', new SAMLStrategy({
entryPoint: adfsEntryPoint,
issuer: '{adfs-url}/login/adfs',
callbackUrl: '{adfs-url}/login/adfs/callback',
cert: "{CERT}",
authnContext:'http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/windows',
identifierFormat: null,
signatureAlgorithm: 'sha256'
}, (profile, done) => {
const upn = profile["http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn"];
const windowsAccountName = profile["http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname"];
const user = new userModel.User(upn, "user");
user.enabled = true;
return done(null, user);
}));
passport.serializeUser((user, done) => {
done(null, user);
});
passport.deserializeUser(function (user, done) {
done(null, user);
});
router.get('/auth/adfs', passport.authenticate('saml', { failureRedirect: "/" }), (req, res) => {
res.redirect('/');
});
router.get('/auth/adfs/callback', passport.authenticate('saml', { failureRedirect: "/" }), (req, res) …Run Code Online (Sandbox Code Playgroud) 我正在使用 express 和 ejs 设置 Web 应用程序,并且需要集成 SAML 身份验证。我有一个 metadata.xml、一个公共证书和一个私钥。现在我想设置此策略并将其用于身份验证。我尝试使用一个名为passport-saml-metadata的模块,但是每当我尝试对其进行身份验证时,它都会说:错误:未知的身份验证策略“saml”,尽管它与其他有效的策略在同一文件中定义和导出。
首先我尝试使用passport-saml模块手动配置SAML,但后来我注意到它们是一个passport-saml-metadata,它可以处理我的元数据文件并建立策略,所以我决定使用这个。我现在有一个“有效”(它在执行中的任何时候都不会抱怨),但是当我调用路由时没有找到策略。同一文件中的其他策略被识别并且可以轻松工作。
护照配置:
// Read the metadata
const reader = new MetadataReader(
fs.readFileSync(path.join(__dirname, './metadata.xml'), 'utf8')
);
const ipConfig = toPassportConfig(reader);
const spPublicCertificate = path.join(__dirname, './server.crt');
const spPrivateKey = path.join(__dirname, './private_key.pem');
const spConfig = {
callbackUrl: `http://localhost:3300/auth/saml/sso/callback`,
logoutCallbackUrl: `http://localhost:3300/auth/saml/slo/callback`,
issuer: '/shibboleth',
privateCert: spPrivateKey
};
const strategyConfig = {
...ipConfig,
...spConfig,
validateInResponseTo: false,
disableRequestedAuthnContext: true,
};
const verifyProfile = (profile, done) => {
return done(null, { ...profile, test: 'xxx' });
};
const samlStrategy …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Okta 作为身份提供者和passport-saml 库在我的Nest.js 应用程序中创建SSO。我阅读了 Nest 认证和passport-saml 的文档。我对示例的理解没有问题,但我确实需要使用具有不同配置的 SAML 策略,这些配置取决于 POST 的请求正文值api/auth/saml。换句话说,我有一个策略,但对于扩展Nest.js 的PassportStrategy 类的自定义LoginSSOStrategy 类,我有不同的入口点、颁发者、证书参数。任何想法我该如何处理?
我passport-saml用于身份验证。为此,我已安装
npm install passport passport-saml --save
Run Code Online (Sandbox Code Playgroud)
我已经使用这个博客Auth0创建了我的 IDP 。
初始化通行证和定义的 saml 策略
app.use(passport.initialize());
passport.use(new passportSaml.Strategy(
{
path: "/login/callback",
entryPoint: "https://qpp1.auth0.com/samlp/bZVOM5KQmhyir5xEYhLHGRAQglks2AIp",
issuer: "passport-saml",
// Identity Provider's public key
cert: fs.readFileSync("./src/cert/idp_cert.pem", "utf8"),
},
(profile, done) => {
console.log("Profile : ",profile);
let user = new Profile({ id: profile["nameID"], userName: profile["http://schemas.auth0.com/nickname"] });
return done(null, user);
}
));
Run Code Online (Sandbox Code Playgroud)
这是路线
app.get("/login",
passport.authenticate("saml", (err, profile) => {
// control will not come here ????
console.log("Profile : ", profile);
})
);
app.post("/login/callback",
(req, res, …Run Code Online (Sandbox Code Playgroud) 我需要实现一个应该能够实现的身份提供者服务(使用node.js)。
如果一切有效,则使用签名的 XML 响应示例进行响应
node.js 中是否有可以处理 SAML 协议的 IdP 端的工具。我熟悉samlify、saml2、Passport-saml,它们似乎都处理协议的服务提供商端。
如果这里提到的软件包可以满足我的需求,您能否指定它们到底如何处理这个问题。任何其他方向和/或提示可能会有帮助。
谢谢
我在记录 ADFS SSO 时遇到此问题。“加密的 SAML 响应没有解密密钥”。从另一个帐户登录成功。有人可以帮我解决这个问题。我正在使用 Express 进行 Passport-saml 工作。
这是我陷入困境的代码快照。
node_modules/passport-saml/lib/passport-saml/saml.js 为 null。在第 623:15 行
if (encryptedAssertions.length == 1) {
if (!self.options.decryptionPvk)
throw new Error('No decryption key for encrypted SAML response');
var encryptedAssertionXml = encryptedAssertions[0].toString();
Run Code Online (Sandbox Code Playgroud) node.js ×6
passport.js ×4
saml ×3
adfs ×2
encryption ×1
idp ×1
javascript ×1
nestjs ×1
reactjs ×1
saml-2.0 ×1