Skip to content

Commit 59f26c6

Browse files
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
1 parent c9e8f70 commit 59f26c6

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

client/external/browser_client.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ import (
1818
"log"
1919
"net/url"
2020
"runtime"
21-
"strings"
2221
"sync"
23-
"time"
2422

2523
"github.com/chromedp/cdproto/fetch"
2624
"github.com/chromedp/cdproto/network"
@@ -134,12 +132,13 @@ func (c *browserClient) targetListener(ev interface{}) {
134132
switch ev := ev.(type) { //nolint:gocritic
135133
case *network.EventRequestWillBeSent:
136134
if ev.Request.URL == `https://signin.aws.amazon.com/saml` {
137-
escsaml := strings.Replace(ev.Request.PostData, `SAMLResponse=`, ``, 1)
138-
saml, err := url.QueryUnescape(escsaml)
135+
// parse and unescape the query string for the key value pair that contains SAMLResponse=xxxx
136+
qs, err := url.ParseQuery(ev.Request.PostData)
139137
if err != nil {
140-
time.Sleep(time.Second * 1)
141-
c.Logger.Debugf("%s", err)
138+
c.Logger.Errorf("Error parsing SAMLResponse: %v", err)
139+
return
142140
}
141+
saml := qs.Get("SAMLResponse")
143142
samlassert := credentials.SamlAssertion(saml)
144143
c.saml = &samlassert
145144
done.Done()

0 commit comments

Comments
 (0)