Loading

Come estrarre un documento XML di Asserzione SAML da un file HAR

Data pubblicazione: Nov 19, 2024
Operazione

OBIETTIVO

Per risolvere i problemi di SSO (Single-Sign-On) basato su SAML a Anypoint Platform, è spesso necessario estrarre i dettagli dell'asserzione SAML SSO dalla richiesta. Questo articolo descrive la procedura per farlo dal file HAR acquisito durante l'SSO a Anypoint Platform.
Fasi

Leggere le Linee guida sulla Sicurezza HAR prima della creazione nei seguenti browser supportati

I file HAR (file di archivio http) possono contenere dati sensibili, tra cui cookie, token di autenticazione e informazioni personali. Questi dati possono creare rischi di sicurezza, ad esempio rappresentazione e accesso non autorizzati. 

Nella creazione di un File HAR, i clienti devono assicurarsi che siano state completate le seguenti procedure di protezione prima che il file venga inviato all'Assistenza di Salesforce e ai Fornitori di terze parti.

  1. Pulire: pulire i file prima di condividerli utilizzando un HAR sanitizer (esempio - Cloudflare HAR sanitizer) oppure manualmente con un editor di testo per nascondere le informazioni sensibili.
  2. Disconnettersi dalle sessioni: durante l'indagine su problemi di mancata autenticazione, uscire da qualsiasi sessione attiva prima della registrazione, per incrementare la sicurezza e impedire l'acquisizione di token di sessione attiva.
  3. Igiene HAR: considerare i file HAR come Riservati. Limitare l'accesso solo al personale appropriato e assicurare l'archiviazione e la trasmissione protetta. I File HAR non devono mai essere caricati non sanificati al di fuori di Salesforce (ad esempio, chatGPT)

 

Fase 1, seguendo l'Articolo Knowledge "Come recuperare i file di archivio HTTP (HAR)" quando viene eseguito SSO a Anypoint Platform.

Fase 2, dopo avere acquisito il file HAR, cercare la richiesta a https://anypoint.mulesoft.com/accounts/login/receive-id e individuare il valore del parametro "SAMLResponse", che è una stringa lunga.

Ad esempio:
 

"request": {
          "method": "POST",
          "url": "https://anypoint.mulesoft.com/accounts/login/receive-id",
          "httpVersion": "HTTP/1.1",
          ...
          "postData": {
            "mimeType": "application/x-www-form-urlencoded",
            "text": "SAMLResponse=PD94b...&RelayState=",
            "params": [
              {
                "name": "SAMLResponse",
                "value": "PD94b..."
              },
              {
                "name": "RelayState",
                "value": ""
              }
            ]
          }
        },


Fase 3, copiare la stringa lunga e decodificare tramite URL.


Per la decodifica, è possibile utilizzare https://www.urldecoder.org/.


Fase 4, copiare la stringa decodificata URL ed effettuare la decodifica base64.


Per la decodifica, è possibile utilizzare https://www.base64decode.org/.

L'output è il documento XML dell'Asserzione SAML in formato leggibile dall'uomo, come:
<?xml version="1.0" encoding="UTF-8"?>
<saml2p:Response Destination="https://anypoint.mulesoft.com/accounts/login/receive-id" ID="id102899906075521711077394618" IssueInstant="2020-10-06T00:49:08.454Z" Version="2.0" xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<saml2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity" xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">http://www.okta.com/xxxxxxxxxxxxxxxxxxxxx</saml2:Issuer>
	<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
		<ds:SignedInfo>
			<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
			<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
			<ds:Reference URI="#id102899906075521711077394618">
				<ds:Transforms>
					<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
					<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
						<ec:InclusiveNamespaces PrefixList="xs" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
					</ds:Transform>
				</ds:Transforms>
				<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
				<ds:DigestValue>...</ds:DigestValue>
			</ds:Reference>
		</ds:SignedInfo>
		<ds:SignatureValue>...</ds:SignatureValue>
		<ds:KeyInfo>
			<ds:X509Data>
				<ds:X509Certificate>...</ds:X509Certificate>
			</ds:X509Data>
		</ds:KeyInfo>
	</ds:Signature>
	<saml2p:Status xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol">
		<saml2p:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
	</saml2p:Status>
	<saml2:Assertion ID="id102899906076315621983006756" IssueInstant="2020-10-06T00:49:08.454Z" Version="2.0" xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:xs="http://www.w3.org/2001/XMLSchema">
		<saml2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity" xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">http://www.okta.com/xxxxxxxxxxxxxxxxxxxxx</saml2:Issuer>
		<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
			<ds:SignedInfo>
				<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
				<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
				<ds:Reference URI="#id102899906076315621983006756">
					<ds:Transforms>
						<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
						<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
							<ec:InclusiveNamespaces PrefixList="xs" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
						</ds:Transform>
					</ds:Transforms>
					<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
					<ds:DigestValue>...</ds:DigestValue>
				</ds:Reference>
			</ds:SignedInfo>
			<ds:SignatureValue>...</ds:SignatureValue>
			<ds:KeyInfo>
				<ds:X509Data>
					<ds:X509Certificate>...</ds:X509Certificate>
				</ds:X509Data>
			</ds:KeyInfo>
		</ds:Signature>
		<saml2:Subject xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">
			<saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">sean.li@mulesoft.com</saml2:NameID>
			<saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
				<saml2:SubjectConfirmationData NotOnOrAfter="2020-10-06T00:54:08.454Z" Recipient="https://anypoint.mulesoft.com/accounts/login/receive-id"/>
			</saml2:SubjectConfirmation>
		</saml2:Subject>
		<saml2:Conditions NotBefore="2020-10-06T00:44:08.454Z" NotOnOrAfter="2020-10-06T00:54:08.454Z" xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">
			<saml2:AudienceRestriction>
				<saml2:Audience>anypoint.mulesoft.com</saml2:Audience>
			</saml2:AudienceRestriction>
		</saml2:Conditions>
		<saml2:AuthnStatement AuthnInstant="2020-10-06T00:49:08.454Z" SessionIndex="id1601945348452.291824165" xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">
			<saml2:AuthnContext>
				<saml2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml2:AuthnContextClassRef>
			</saml2:AuthnContext>
		</saml2:AuthnStatement>
		<saml2:AttributeStatement xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">
			<saml2:Attribute Name="firstname" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified">
				<saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">Sean</saml2:AttributeValue>
			</saml2:Attribute>
			<saml2:Attribute Name="lastname" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified">
				<saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">Li</saml2:AttributeValue>
			</saml2:Attribute>
			<saml2:Attribute Name="email" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified">
				<saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">sean.li@mulesoft.com</saml2:AttributeValue>
			</saml2:Attribute>
			<saml2:Attribute Name="group" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified">
				<saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">...</saml2:AttributeValue>
				<saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">...</saml2:AttributeValue>
			</saml2:Attribute>
		</saml2:AttributeStatement>
	</saml2:Assertion>
</saml2p:Response>



 

 

Numero articolo Knowledge

001115955

 
Caricamento
Salesforce Help | Article