Skip to content

Commit

Permalink
Try to choose one time code from challenge selection
Browse files Browse the repository at this point in the history
  • Loading branch information
edw-defang committed Jun 6, 2024
1 parent 2f94cb4 commit 8644170
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions pkg/provider/googleapps/googleapps.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,17 +559,23 @@ func (kc *Client) loadChallengeEntryPage(doc *goquery.Document, submitURL string
return true
})

if challengeEntry == "" {
return nil, errors.New("unable to find supported second factor")
if challengeEntry != "" {
query := fmt.Sprintf(`[data-challengeentry="%s"]`, challengeEntry)
responseForm, newActionURL, err := extractInputsByFormQuery(doc, query)
if err != nil {
return nil, errors.Wrap(err, "unable to extract challenge form")
}
return kc.loadChallengePage(newActionURL, submitURL, responseForm, loginDetails)
}

query := fmt.Sprintf(`[data-challengeentry="%s"]`, challengeEntry)
responseForm, newActionURL, err := extractInputsByFormQuery(doc, query)
if err != nil {
return nil, errors.Wrap(err, "unable to extract challenge form")
// New layout, form does not have any id
formData, actionURL, err := extractInputsByFormQuery(doc, "")
if err != nil && actionURL != "" {
return nil, errors.New("could not find any forms with actions")
}

return kc.loadChallengePage(newActionURL, submitURL, responseForm, loginDetails)
formData.Set("challenge", "5,undefined")
return kc.loadChallengePage(actionURL, submitURL, formData, loginDetails)
}

func (kc *Client) postJSON(submitURL string, values map[string]string, referer string) (*http.Response, error) {
Expand Down

0 comments on commit 8644170

Please sign in to comment.