Skip to content

Commit

Permalink
Merge pull request #885 from myunggi-jung/fix_infinite_loop_for_keycloak
Browse files Browse the repository at this point in the history
fix infinite loop for keycloak
  • Loading branch information
wolfeidau authored Sep 12, 2022
2 parents ba5168e + 0f03386 commit 700801d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/provider/keycloak/keycloak.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (kc *Client) doAuthenticate(authCtx *authContext, loginDetails *creds.Login
}

samlResponse, err := extractSamlResponse(doc)
if err != nil && authCtx.authenticatorIndexValid {
if err != nil && authCtx.authenticatorIndexValid && passwordValid(doc) {
return kc.doAuthenticate(authCtx, loginDetails)
}
return samlResponse, err
Expand Down Expand Up @@ -352,6 +352,18 @@ func extractSamlResponse(doc *goquery.Document) (string, error) {
return samlAssertion, err
}

func passwordValid(doc *goquery.Document) bool {
var valid = true
doc.Find("span#input-error").Each(func(i int, s *goquery.Selection) {
text := s.Text()
if strings.Contains(text, "Invalid username or password.") {
valid = false
return
}
})
return valid
}

func containsTotpForm(doc *goquery.Document) bool {
// search totp field at Keycloak < 8.0.1
totpIndex := doc.Find("input#totp").Index()
Expand Down

0 comments on commit 700801d

Please sign in to comment.