From 59f26c635887c1ae75a62da2ac6598e20197832c Mon Sep 17 00:00:00 2001 From: Neminda Prabhashwara Date: Tue, 2 May 2023 18:57:00 +0530 Subject: [PATCH] browser-client-SAMLResponse: Parse response query string to get SAMLResponse key value pair (#106) * bugfix/browser-client-SAMLResponse: Add query string parsing to get the SAMLResponse --- client/external/browser_client.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/client/external/browser_client.go b/client/external/browser_client.go index 7748d9d..eaaac95 100644 --- a/client/external/browser_client.go +++ b/client/external/browser_client.go @@ -18,9 +18,7 @@ import ( "log" "net/url" "runtime" - "strings" "sync" - "time" "github.com/chromedp/cdproto/fetch" "github.com/chromedp/cdproto/network" @@ -134,12 +132,13 @@ func (c *browserClient) targetListener(ev interface{}) { switch ev := ev.(type) { //nolint:gocritic case *network.EventRequestWillBeSent: if ev.Request.URL == `https://signin.aws.amazon.com/saml` { - escsaml := strings.Replace(ev.Request.PostData, `SAMLResponse=`, ``, 1) - saml, err := url.QueryUnescape(escsaml) + // parse and unescape the query string for the key value pair that contains SAMLResponse=xxxx + qs, err := url.ParseQuery(ev.Request.PostData) if err != nil { - time.Sleep(time.Second * 1) - c.Logger.Debugf("%s", err) + c.Logger.Errorf("Error parsing SAMLResponse: %v", err) + return } + saml := qs.Get("SAMLResponse") samlassert := credentials.SamlAssertion(saml) c.saml = &samlassert done.Done()