Skip to content

Commit

Permalink
browser-client-SAMLResponse: Parse response query string to get SAMLR…
Browse files Browse the repository at this point in the history
…esponse key value pair (#106)

* bugfix/browser-client-SAMLResponse: Add query string parsing to get the SAMLResponse
  • Loading branch information
NemindaPiyasena authored May 2, 2023
1 parent c9e8f70 commit 59f26c6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions client/external/browser_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import (
"log"
"net/url"
"runtime"
"strings"
"sync"
"time"

"github.com/chromedp/cdproto/fetch"
"github.com/chromedp/cdproto/network"
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 59f26c6

Please sign in to comment.