passport-saml问题用于解码和验证已签名的SAML响应
问题描述:
我们需要实施基于SAML的安全身份验证。我们的IDP将是Okta和OneLogin。为此,我们在我们的node.js express应用程序中使用“passport”+“passport-saml”。我们用下面的策略配置在SP侧Okta-passport-saml问题用于解码和验证已签名的SAML响应
var oktaLoginStrategy = {
host: 'http://localhost:3000',
path: '/login/callback',
realm: 'urn:node:app',
entryPoint: "https://dev-528399.oktapreview.com/app/builtiodev528399_oktasp1_1/exkbbi8vwj2OsHjbE0h7/sso/saml",
issuer: "http://www.okta.com/exkbbi8vwj2OsHjbE0h7",
additionalParams: {
'RelayState': "test"
},
signatureAlgorithm: 'sha256',
decryptionPvk: privateKey,
privateCert: privateKey,
cert: oktaPublicKey,
identifierFormat: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress'
};
和OneLogin我们使用 -
var oneLoginStrategy = {
host: 'http://localhost:3000',
path: '/login/callback',
realm: 'urn:node:app',
entryPoint: "https://flow-dev.onelogin.com/trust/saml2/http-post/sso/686218",
issuer: "https://app.onelogin.com/saml/metadata/686218",
additionalParams: {
'RelayState': "test"
},
signatureAlgorithm: 'sha256',
decryptionPvk: privateKey,
privateCert: privateKey,
cert: oneLoginPublicKey,
validateInResponseTo: true,
identifierFormat: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress'
};
但1563它给错误为“无法读取属性未定义‘的getAttribute’”而对于OneLogin,它会将错误提示为“无效签名”。此外,我们调试到模块中,发现Okta在找到算法和OneLogin时会中断,它能够解密'CipherData',但在验证签名时会中断。
我们的私人密钥格式是 -
-----BEGIN PRIVATE KEY-----
-----END PRIVATE KEY-----
请帮我们进入这一点。
答
这里的问题来自Okta SAML断言格式,我们对xml加密模块的“decryptKeyInfo”函数进行了更改,该函数在passport-saml下用于从断言中查找“keyEncryptionMethod”。关于OneLogin,这是我们的设置问题。