Skip to content

Commit

Permalink
Versentgh-36: ADFS + Duo works
Browse files Browse the repository at this point in the history
  • Loading branch information
dboitnot committed Jul 10, 2022
1 parent d3a9b10 commit ab4f977
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 5 additions & 3 deletions pkg/duo/duo.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ func getTxResultJson(httpClient *provider.HTTPClient, duoHost string, sid string
}

func VerifyDuoMfa(httpClient *provider.HTTPClient, loginDetails *creds.LoginDetails, parent string, duoHost string, duoSignature string) (string, error) {
duoSignature = strings.Split(duoSignature, ":")[0]
sigParts := strings.Split(duoSignature, ":")

session, err := getDuoSession(httpClient, parent, duoHost, duoSignature)
session, err := getDuoSession(httpClient, parent, duoHost, sigParts[0])
if err != nil {
return "", errors.Wrap(err, "error fetching Duo SID")
}
Expand Down Expand Up @@ -290,5 +290,7 @@ func VerifyDuoMfa(httpClient *provider.HTTPClient, loginDetails *creds.LoginDeta
return "", errors.Wrap(err, "error getting Duo result json")
}

return resultJson, nil
cookie := gjson.Get(resultJson, "response.cookie").String()

return fmt.Sprintf("%s:%s", cookie, sigParts[1]), nil
}
5 changes: 2 additions & 3 deletions pkg/provider/adfs/adfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/PuerkitoBio/goquery"
"github.com/pkg/errors"
"github.com/tidwall/gjson"

"github.com/versent/saml2aws/v2/pkg/cfg"
"github.com/versent/saml2aws/v2/pkg/creds"
Expand Down Expand Up @@ -187,15 +186,15 @@ func (ac *Client) Authenticate(loginDetails *creds.LoginDetails) (string, error)
return samlAssertion, errors.New("context field not found")
}

duoJson, err := duo.VerifyDuoMfa(ac.client, loginDetails, authSubmitURL, duoHost, duoSigRequest)
duoCookie, err := duo.VerifyDuoMfa(ac.client, loginDetails, authSubmitURL, duoHost, duoSigRequest)
if err != nil {
return samlAssertion, errors.Wrap(err, "error in Duo MFA process")
}

duoForm := url.Values{}
duoForm.Add("Context", duoContext)
duoForm.Add("AuthMethod", "DuoAdfsAdapter")
duoForm.Add("sig_response", gjson.Get(duoJson, "response.cookie").String())
duoForm.Add("sig_response", duoCookie)

doc, err = ac.submit(authSubmitURL, duoForm)
case UNKNOWN:
Expand Down

0 comments on commit ab4f977

Please sign in to comment.