Skip to content

Commit 2353db9

Browse files
committed
feat(pingone): handle device profiling form
See "PingOne Integrations > PingOne Protect Integration Kit > Device profiling methods" for more details. https://docs.pingidentity.com/integrations/pingone/pingone_protect_integration_kit/pf_p1_protect_ik_device_profiling_methods.html
1 parent 65195ee commit 2353db9

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

pkg/provider/pingone/pingone.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ func (ac *Client) follow(ctx context.Context, req *http.Request) (string, error)
112112
} else if docIsRefresh(doc) {
113113
logger.WithField("type", "refresh").Debug("doc detect")
114114
handler = ac.handleRefresh
115+
} else if docIsFormDeviceProfiling(doc) {
116+
logger.WithField("type", "device-profiling").Debug("doc detect")
117+
handler = ac.handleFormDeviceProfiling
115118
}
116119
if handler == nil {
117120
html, _ := doc.Selection.Html()
@@ -273,6 +276,22 @@ func (ac *Client) handleFormSelectDevice(ctx context.Context, doc *goquery.Docum
273276
return ctx, req, err
274277
}
275278

279+
func (ac *Client) handleFormDeviceProfiling(ctx context.Context, doc *goquery.Document, res *http.Response) (context.Context, *http.Request, error) {
280+
form, err := page.NewFormFromDocument(doc, "")
281+
if err != nil {
282+
return ctx, nil, errors.Wrap(err, "error extracting redirect form")
283+
}
284+
285+
form.URL, err = makeAbsoluteURL(form.URL, makeBaseURL(res.Request.URL))
286+
if err != nil {
287+
return ctx, nil, err
288+
}
289+
290+
req, err := form.BuildRequest()
291+
292+
return ctx, req, err
293+
}
294+
276295
func docIsLogin(doc *goquery.Document) bool {
277296
return doc.Has("input[name=\"pf.pass\"]").Size() == 1
278297
}
@@ -301,6 +320,10 @@ func docIsFormResume(doc *goquery.Document) bool {
301320
return doc.Find("input[name=\"RelayState\"]").Size() == 1 || doc.Find("input[name=\"Resume\"]").Size() == 1
302321
}
303322

323+
func docIsFormDeviceProfiling(doc *goquery.Document) bool {
324+
return doc.Has("form[id=\"device-profile-form\"]").Size() == 1
325+
}
326+
304327
func docIsFormRedirectToTarget(doc *goquery.Document, target string) bool {
305328
if target == "" {
306329
target = "https://signin.aws.amazon.com/saml"

0 commit comments

Comments
 (0)