gpt4 book ai didi

javascript - 如何使用像 samling 这样的免费 IdP 测试 saml2-js?

转载 作者:搜寻专家 更新时间:2023-11-01 00:36:50 25 4
gpt4 key购买 nike

我对 SAML 身份验证还很陌生,所以很多概念对我来说还是很陌生。我最初的目标是创建一个可以进行 SAML 身份验证的 node.js 脚本。

在做了一些研究之后,我得到了一些更具体的信息,现在我的目标是制作一个 node.js 脚本作为服务提供者并连接到免费的在线身份提供者以进行 SAML 身份验证。

对于我的服务提供商,我想使用类似 saml2-js 的东西并将其连接到身份提供者,如 samling .

我已经尝试使用提供的示例 here (来自 saml2-js 的 Express 示例)但我不明白如何将它连接到 samling 或连接后在 samling 中做什么。

更具体地说,这些是我在填充时遇到问题的值:

// Create service provider
var sp_options = {
entity_id: "https://sp.example.com/metadata.xml",
private_key: fs.readFileSync("sp_privatekey.pem").toString(),
certificate: fs.readFileSync("sp_certificate.pem").toString(),
assert_endpoint: "https://sp.example.com/assert"
};

// Create identity provider
var idp_options = {
sso_login_url: "https://idp.example.com/login",
sso_logout_url: "https://idp.example.com/logout",
certificates: [fs.readFileSync("idp_certificate.pem").toString()]
};

我也对 passport-saml 等替代方案持开放态度,只要我能连接到 samling 或类似的东西。

谢谢!

最佳答案

我不熟悉 samling,但快速浏览一下他们的网站似乎表明他们执行 IDP 启动的 SSO(即,来自身份提供者的登录)。此外,他们似乎没有加密他们发送的断言。

因此,您无需担心其中的许多设置。 sp_options 中的private_keycertificate 用于解密断言,因此您可以完全删除它们。 entity_id 设置应该是 IDP 的 Issuer(默认情况下似乎是 http://capriza.com/samling)。 assert_endpoint 用于 SP 启动的流,因此您可以将其保留为默认值,因为此处不会使用它。此外,由于 SAML 响应不加密断言,您需要将 allow_unencrypted_assertion 标志设置为 true

对于 idp_optionssso_login_urlsso_logout_url 指向可以找到您的服务器的 URL。这些在元数据文件中公开,但您手动将其输入到采样中,因此您可以保留这些默认值,因为它们也将未被使用。最后,certificates 数组应该包含 samling 的签名证书,它看起来是页面右下角的文本框。您可以将其复制到一个文件,然后在 fs.readFileSync 中设置该路径。

最终的配置应该是这样的:

// Create service provider
var sp_options = {
entity_id: "http://capriza.com/samling",
assert_endpoint: "https://sp.example.com/assert",
allow_unencrypted_assertion: true
};

// Create identity provider
var idp_options = {
sso_login_url: "https://idp.example.com/login",
sso_logout_url: "https://idp.example.com/logout",
certificates: [fs.readFileSync("idp_certificate.pem").toString()]
};

其中 idp_certificate.pem 包含页面右下角的公钥。然后只需填写任何您想要的名称标识符和 http://localhost:3000/assert 作为 samling 中的回调 URL。

关于javascript - 如何使用像 samling 这样的免费 IdP 测试 saml2-js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48652429/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com