Parsing and saving value from SAML response

Question

I am using Invoke-RestMethod to do a POST and would like to parse out a value I am returned. The reply is HTML with a bunch of stuff but I only care about this part and what is supplied as the value:

<form id="SamlForm" method="post">
  <input name="RelayState" id="RelayState" type="hidden" />
  <input name="SAMLResponse" id="SAMLResponse"  type="hidden" value="theTextIwant..." />

Any help is appreciated.

Posted Apr 12, 2021, 5:19 PM UTC · edited

27
waelder_at•

Its plain XML so [xml]

2
TinyRickSystemsOP•

Sorry can you expand on that more? This is definitely not my forte as you can tell.

2
waelder_at•
2
TinyRickSystemsOP•

Unfortunately this doesn't work as the POST response is much more than the simple info I supplied in the original post. And some of the returned values syntax breaks the XML parser. I was thinking some regex to pull the value out.

2
waelder_at•

If you extract the assertion it must be xml. Otherwise its not standard saml.

With regex you xan achieve the same, its just not so straightforward.

2