我正在使用护照 saml 从 IDP 注销这是我的代码:
module.exports = function logout(app, samlStrategy, config) {
app.get('/logout', (req, res) => {
const { webUser } = req;
const { role, nameID } = webUser || {};
if (role === ROLENAME_WEB_USER && nameID) {
samlStrategy.logout(req, (err, requestUrl) => {
// redirect to the IdP with the SAML logout request
console.log(`req url is is:${requestUrl}`);
res.redirect(requestUrl);
});
} else {
res.redirect(LOGGED_OUT_URL);
}
});
app.post(config.externalSSO.logoutCallbackPath, (req, res) => {
// console.log('SAML logout callback:');
// console.log(req);
res.redirect(LOGGED_OUT_URL);
});
};
这是我的护照 saml 配置:
loginPath: process.env.EXTERNAL_SSO_LOGIN_PATH,
callbackUrl: process.env.BASE_ADDRESS + process.env.EXTERNAL_SSO_CALLBACK_PATH,
callbackPath: process.env.EXTERNAL_SSO_CALLBACK_PATH,
logoutUrl: process.env.EXTERNAL_SSO_LOGOUT_URL,
// logoutCallbackPath: '/logout/external/callback',
logoutCallbackUrl: process.env.EXTERNAL_SSO_LOGOUT_URL,
metadataPath: `${process.env.EXTERNAL_SSO_LOGIN_PATH}/metadata`,
entryPoint: process.env.EXTERNAL_SSO_ENTRYPOINT,
issuer: process.env.EXTERNAL_SSO_ISSUER,
idpPublicCert: process.env.EXTERNAL_SSO_IDP_CERT,
spPrivateCert: process.env.EXTERNAL_SSO_SP_SIGNING_PRIVATE_KEY,
decryptionPvk: process.env.EXTERNAL_SSO_SP_DECRYPTION_PRIVATE_KEY,
decryptionCert: process.env.EXTERNAL_SSO_SP_DECRYPTION_PUBLIC_KEY,
authnRequestBinding: process.env.EXTERNAL_SSO_AUTHN_REQUEST_BINDING,
问题是我试图摆脱上面代码中的第二个 api 调用,因为重定向到 LOGGED_OUT_URL 停止了我的 SLO 进程,所以我更改并部署在 dev env 上,我得到了这个异常:
{"error":{"message":"Not found"}}
有线的事情是仍然将我重定向到 logoutCallbackPath url!