Loading

How to Extract Anypoint SAML Assertion XML From a HAR File

Udgivelsesdato: Nov 3, 2026
Opgave

Goal

To troubleshoot SAML-based single sign-on (SSO) to Anypoint Platform, you often need to read the SAML assertion that the identity provider (IdP) sends. This article shows how to find the SAML response in an HTTP Archive (HAR) file captured during an SSO sign-in and decode it into readable XML.

Trin

Before You Start: HAR Security Guidelines

HAR files can contain sensitive data, including cookies, authentication tokens, and personal information, which can lead to impersonation and unauthorized access. A SAML response is itself a sign-in credential until it expires. Before you send a HAR file to Salesforce Support or a third party, complete these safeguards:

  1. Sanitize: Redact sensitive information with a HAR sanitizer (for example, the Cloudflare HAR sanitizer) or manually in a text editor.
  2. Log out of sessions: If you are investigating an issue that is not about authentication, log out of active sessions before recording so that active session tokens are not captured.
  3. HAR hygiene: Treat HAR files as restricted. Limit access to the people who need them, store and transmit them securely, and never upload an unsanitized HAR file outside Salesforce (for example, to a generative AI tool).

Extract the SAML Assertion

  1. Capture a HAR file while you sign in to Anypoint Platform through SSO. Follow How to Retrieve HTTP Archive Files (HAR) for MuleSoft System Troubleshooting.
  2. Open the HAR file in a text editor and search for receive-id. Find the POST request whose URL path ends in /receive-id. This is the assertion consumer service (ACS) URL configured in your IdP; its host and path depend on your control plane (US, EU, or Gov) and identity provider, as described in Configuring SAML SSO for Anypoint Platform.
  3. In that request, find the postData parameter named SAMLResponse and copy its value, which is a long string.

The request looks similar to this excerpt from a HAR file (values shortened):

"request": {
  "method": "POST",
  "url": "<your ACS URL ending in /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": ""
      }
    ]
  }
},

Decode the SAML Response Locally

The SAMLResponse value is Base64-encoded and can also be URL-encoded (for example, it contains %2B or %3D). Decode it in two steps: URL-decode it, then Base64-decode the result. URL-decoding a value that is not URL-encoded leaves it unchanged, so you can always run both steps. Decode it on your own computer rather than pasting it into a third-party website, because the response contains user identity details and stays valid until it expires.

  1. Save the copied value to a file named samlresponse.txt.
  2. Decode it with one of the following methods.

This Python 3 command URL-decodes and then Base64-decodes the file and prints the XML:

python3 -c "import urllib.parse,base64;print(base64.b64decode(urllib.parse.unquote(open('samlresponse.txt').read().strip())).decode())"

Alternatively, in your browser's Developer Tools console, run this JavaScript expression with the copied value in place of the placeholder:

atob(decodeURIComponent("PASTE_SAMLRESPONSE_VALUE_HERE"))

The output is the SAML response XML, including the assertion, similar to this example (signatures and certificates shortened):

<?xml version="1.0" encoding="UTF-8"?>
<saml2p:Response Destination="<your ACS URL>" 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"><your IdP issuer></saml2:Issuer>
	<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">...</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"><your IdP issuer></saml2:Issuer>
		<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">...</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">jane.doe@example.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="<your ACS URL>"/>
			</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 xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">Jane</saml2:AttributeValue>
			</saml2:Attribute>
			<saml2:Attribute Name="lastname" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified">
				<saml2:AttributeValue xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">Doe</saml2:AttributeValue>
			</saml2:Attribute>
			<saml2:Attribute Name="email" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified">
				<saml2:AttributeValue xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">jane.doe@example.com</saml2:AttributeValue>
			</saml2:Attribute>
			<saml2:Attribute Name="group" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified">
				<saml2:AttributeValue xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">...</saml2:AttributeValue>
			</saml2:Attribute>
		</saml2:AttributeStatement>
	</saml2:Assertion>
</saml2p:Response>

Compare the Issuer, Audience, NameID, Recipient, time conditions, and attributes in the assertion with the identity provider settings in Anypoint Platform Access Management.

Vidensartikelnummer

001115955

 
Indlæser
Salesforce Help | Article