How to handle site minder authentication

413 views
Skip to first unread message

Ellen Kang

unread,
Apr 19, 2018, 2:33:15 PM4/19/18
to REST assured
The API I am testing is redirected to site minder login page first, please see the html below , no action in the form, form authentication doesn't work.

given().auth().basic(<username>, <password>).when().get(uri);  - returns html file of the site minder.

How to do under such situation?



<!-- SiteMinder Encoding=ISO-8859-1; -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
  <title>PPS Authentication via SiteMinder Password Services</title>
<SCRIPT LANGUAGE="JavaScript">
function resetCredFields()
{
  document.Login.PASSWORD.value = "";
}
function submitForm()
{
     document.Login.submit();
}
</SCRIPT>
</head>
<body BGCOLOR="#D2FFFF" TEXT="#000000" onLoad = "resetCredFields();">
<!-- Customer Brand -->
<!--IMG alt=Logo src="/siteminderagent/dmspages/netegrity_logo.gif"-->
<form NAME="Login" METHOD="POST">
<INPUT TYPE=HIDDEN NAME="SMENC" VALUE="ISO-8859-1">
<INPUT type=HIDDEN name="SMLOCALE" value="US-EN">
<center>
<!-- outer table with border -->
<table width="50%" height=200 border=1 cellpadding=0 cellspacing=0 >
<tr>
  <td ALIGN="CENTER" VALIGN="CENTER" HEIGHT=40 COLSPAN=4 NOWRAP BGCOLOR="#FFFFCC">
       <font size="+2" face="Arial,Helvetica">
  <b>PPS</b></font>
     </td>
  </tr>
  <tr>
    <td>
   <!-- Login table -->
      <table WIDTH="100%" HEIGHT=200 BGCOLOR="#FFFFFF" border=0 cellpadding=0 cellspacing=0 >
       
 <tr>
   <td ALIGN="CENTER" VALIGN="CENTER" HEIGHT=40 COLSPAN=4 NOWRAP BGCOLOR="#FFFFFF">
  <font size="+1" face="Arial,Helvetica">
  <b>Please Login</b></font>
       </td>
 </tr>
 <tr> <td colspan=4 height=10> <font size=1>   </font> </td> </tr>
 <tr>
   <td WIDTH=20 >&nbsp;</td>
   <td ALIGN="LEFT" >
      <b><font size=-1 face="arial,helvetica" > Username: </font></b>
    </td>
   <td ALIGN="LEFT" >
     <input type="text" name="USER" size="30" style="margin-left: 1px">
    </td>
   <td WIDTH=20 >&nbsp;</td>
 </tr>
 <tr> <td colspan=4 height=10> <font size=1>   </font> </td> </tr>
 <tr>
   <td WIDTH=20 >&nbsp;</td>
   <td >
      <b><font size=-1 face="arial,helvetica" > Password: </font></b>
       </td>
   <td ALIGN="left" >
     <input type="password" name="PASSWORD" size="30" style="margin-left: 1px">
   </td>
   <td WIDTH=20 >&nbsp;</td>
 </tr>
 <tr> <td colspan=4 height=10> <font size=1>   </font> </td> </tr>
 <tr>
   <td colspan=4 NOWRAP WIDTH="50%" HEIGHT="25" align="CENTER">
       <input type=hidden name=smquerydata value="">
       <input type=hidden name=smauthreason value="0">
       <input type=hidden name=smagentname value="OL9V/qlt7/7L+n9klS4+VH5DvC2Gidql5iLqO6CXQTQPU4e4QgjI67sYeeeFAewI">
       <input type=hidden name=postpreservationdata value="">
       <input type="button" value="Login" onclick="submitForm();">
   </td>
 </tr>
 <tr> <td colspan=4 height=5> <font size=1>   </font> </td> </tr>
      </table>
    </td>
  </tr>
</table>
</form></center>
<script language="javascript">
  document.forms["Login"].elements["USER"].focus();
</script>
</body>
</html>

Johan Haleby

unread,
Apr 20, 2018, 2:53:37 AM4/20/18
to rest-a...@googlegroups.com
This login is done via javascript you have to find out the path/location to where the form is posted (for example by using chrome developer tools or wireshark) and the create a FormAuthConfig that includes this path. For example:

given().auth().form("username", "password", new FormAuthConfig("/the/path/you/have/to/find", "name", "password")). ..

Now it seems that there are some hidden fields in your response that might be required for authentication to succeed so you might need to do something like this:

given().auth().form("username", "password", new FormAuthConfig("/the/path/you/have/to/find", "name", "password")).withCsrfFieldName("smagentname"). ..


If additional fields are required you'd have to first do a get request to receive the page and then parse out all the fields using XmlPath with CompatibilityMode HTML and then construct the POST request yourself:

given().formParam("user", "username").formParam("password", "password").formParam("smquerydata", ...).formParam("smauthreason", ...). ..

/Johan

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ellen

unread,
Apr 20, 2018, 8:51:57 PM4/20/18
to REST assured

Thank you so much Johan.



I used the Chrome developer tool and found the following in the Response Headers



Location:https://xxxxxx.xx.xxx.org:1443/login.fcc?TYPE=33554433&REALMOID=06-000d1a64-ea69-1947-a311-9b850a33a0be&GUID=&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=-SM-OL9V%2fqlt7%2f7L%2bn9klS4%2bVH5DvC2Gidql5iLqO6CXQTQPU4e4QgjI67sYeeeFAewI&TARGET=-SM-http%3a%2f%2XXXXXXXXX



Is https://xxxxxx.xx.xxx.org:1443/login.fcc? the path for FormAuthConfig()?

I tried given().auth().form("username", "password", new FormAuthConfig("/the/path/you/have/to/find", "name", "password")).withCsrfFieldName("smagentname").when().get(uri); doesn't work


I am trying to construct post request, Can you give me some code example?



Thanks


Ellen

To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.

Ellen

unread,
Apr 23, 2018, 8:06:10 PM4/23/18
to REST assured


cannot do authentication at the site minder page directly, it returns HTTP 500.


RequestSpecBuilder builder = new RequestSpecBuilder();

RequestSpecification spec = builder.setAuth(authScheme)

.addParam("password","<password>")

.addParam("user","<user name>")

.build();

 

Response res1 = RestAssured.given().spec(spec).when().post(API_uri);

String jsString = res1.thenReturn().asString();



returns


<HTML><HEAD><TITLE></TITLE></HEAD><BODY onLoad="document.AUTOSUBMIT.submit();">This page is used to hold your data while you are being authorized for your request.<BR><BR>You will be forwarded to continue the authorization process. If this does not happen automatically, please click the Continue button below.<FORM NAME="AUTOSUBMIT" METHOD="POST" ENCTYPE="application/x-www-form-urlencoded" ACTION=https://xxxx.xx.xxx.org:1443/login.fcc?TYPE=33554433&REALMOID=06-000d1a64-ea69-1947-a311-9b850a33a0be&GUID=&SMAUTHREASON=0&METHOD=POST&SMAGENTNAME=-SM-OL9V%2fqlt7%2f7L%2bn9klS4%2bVH5DvC2Gidql5iLqO6CXQTQPU4e4QgjI67sYeeeFAewI&TARGET=-SM-http%3a%2f%2xxxx%2exx%2efrb%2exxx%3a1080%xxxxxxx%2fxxxx%2fxxxx><INPUT TYPE="HIDDEN" NAME="SMPostPreserve" VALUE="2xAzhdGH6rDEWmK0cYtjiILWj7oPMaHev1xXP8QkZiKNBNSGZ0eCscoACs25RPl2TV2v/Gs2ctJ2Ugqd65x+kUlCrTZR6/ou"><INPUT TYPE="SUBMIT" VALUE="Continue"></FORM></BODY></HTML>


I don't know how to construct the post request with form auth, can I hard code the ACTION in new FormAuthConfig() with the information above?

Thanks
Ellen

Ellen

unread,
Apr 24, 2018, 6:36:28 PM4/24/18
to REST assured

karthi v

unread,
May 17, 2018, 12:08:06 AM5/17/18
to REST assured
Hi Ellen,

Were you able to succeed with the siteminder authentication? If yes, can you please share the code sample?

Thanks,
Karthi
Reply all
Reply to author
Forward
0 new messages