@@ -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+
276295func 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+
304327func docIsFormRedirectToTarget (doc * goquery.Document , target string ) bool {
305328 if target == "" {
306329 target = "https://signin.aws.amazon.com/saml"
0 commit comments