Интеграция Okta SAML Single logout (SLO) в ServiceProvider. Я пытаюсь сделать SLO запрос двумя способами.
1. HTTP Redirect привязка 2. HTTP POST привязка. Я настроил SLO в панели приборов Okta.
Вот мой запрос на привязку HTTP Redirect:
function create_logout_request(issuer, name_id, session_index, destination) {
var id, xml;
id = '_' + crypto.randomBytes(21).toString('hex');
xml = xmlbuilder.create({
'samlp:LogoutRequest': {
'@xmlns:samlp': 'urn:oasis:names:tc:SAML:2.0:protocol',
'@xmlns': 'urn:oasis:names:tc:SAML:2.0:assertion',
'@ID': id,
'@Version': '2.0',
'@IssueInstant': (new Date()).toISOString(),
'@Destination': destination,
'Issuer': issuer,
'NameID': {
'@Format': 'urn:oasis:names:tc:SAML:2.0:nameidformat:emailAddress', // attributes start with @
'#text': name_id // text node
},
'samlp:SessionIndex': session_index
}
}).end();
return {
id: id,
xml: xml
};
}
let xmlReqObj = create_logout_request(options.entity_id, options.name_id, options.session_index, idp_options.sso_logout_url);
let newXmlReq = xmlReqObj.xml.replace('<?xml version="1.0"?>', "");
let appendXmlVersion = '<?xml version="1.0" encoding="UTF-8"?>' + newXmlReq;
let input = new Buffer(appendXmlVersion);
let compressed = zlib.deflateSync(input);
var samlEncodeReq = compressed.toString('base64')
let queryStr = "SAMLRequest=" + encodeURIComponent(samlEncodeReq) + "&SigAlg=" + encodeURIComponent("http://www.w3.org/2000/09/ xmldsig#rsa-sha256") + "&RelayState=" + encodeURIComponent(options.relay_state);
let sign = crypto.createSign('RSA-SHA256');
sign.update(queryStr);
let signature = sign.sign(sp_options.private_key, 'base64');
let logout_url = idp_options.sso_logout_url + "?" + queryStr + "&Signature=" + encodeURIComponent(signature);
res.redirect(logout_url);
Вот мой запрос HTTP для привязки POST:
var html = [
'<!DOCTYPE html>',
'<html>',
'<head>',
'<meta charset="utf-8">',
'<meta http-equiv="x-ua-compatible" content="ie=edge">',
'</head>',
'<body onload="document.forms[0].submit()">',
'<noscript>',
'<p><strong>Note:</strong> Since your browser does not support JavaScript, you must press the button below once to proceed.</p>',
'</noscript>',
'<form method="post" id="myForm" action="https://lantronix-sharath.okta.com/app/lantronixorg730497_testsaml_1/exk5zzbhqflRfc0uM355/slo/saml">',
'<input type="hidden" name="SAMLRequest" value="' + samlEncodeReq + '" />',
'<input type="hidden" name="RelayState" value="' + options.relay_state + '" />',
'<input type="submit" value="Submit" />',
'</form>',
'<script> function submitForm(){ document.getElementById("myForm").submit(); } submitForm(); </script>',
'</body>',
'</html>'
].join('\r\n');
res.set('Content-Type', 'text/html');
res.send(html);
res.render(html);
Я получил ответ SAML, как показано ниже
<saml2p:Status xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol"><saml2p:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:RequestDenied"/></saml2p:Status>
Я пытался использовать два типа xml-форм SAML Logout Request. Они как ниже
<?xml version="1.0"?><samlp:LogoutRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns="urn:oasis:names:tc:SAML:2.0:assertion" ID="_d72db96681b9f6649ae862b21f5e175e74ed7aae19" Version="2.0" IssueInstant="2018-08-03T07:14:02.548Z" Destination="https://lantronix-sharath.okta.com/app/lantronixorg730497_testsaml_1/exk5zzbhqflRfc0uM355/slo/saml"><Issuer>https://192.168.50.68:3000</Issuer><NameID Format="urn:oasis:names:tc:SAML:2.0:nameidformat:emailAddress">csharath@lantronix.com</NameID><samlp:SessionIndex>_72507c647a10dd290a14b2991c2e88f5817b6ad332</samlp:SessionIndex></samlp:LogoutRequest>
<?xml version="1.0"?><samlp:LogoutRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns="urn:oasis:names:tc:SAML:2.0:assertion" ID="_c942f734072c29dbc745e9ce764d7777b456908442" Version="2.0" IssueInstant="2018-08-03T00:53:36.607Z" Destination="https://lantronix-sharath.okta.com/app/lantronixorg730497_testsaml_1/exk5zzbhqflRfc0uM355/slo/saml"><Issuer>https://192.168.1.2:3000</Issuer><NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress">csharath@lantronix.com</NameID><samlp:SessionIndex>_4865368d3755a7c3a032134867bd769e1953d74790</samlp:SessionIndex></samlp:LogoutRequest>
Пожалуйста, помогите мне, каков формат запроса SAML Logout?