Search code examples
curlsiteminder

How to post siteminder credentials via curl?


When executing a REST command via curl, I get a HTTP 302 response back, redirecting to the .fcc file, so I need to autheticate first.

According to cURL and Siteminder authentication I need to post my credentials to the fcc file.

How do I do that? (username and password)

This is my original curl command:

curl --request PUT --data @/src/test.xml https://xyz/api/1.0/123 --header Content-Type:application/xml' 

The 302 response:

<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://test.abc.net/login.fcc?TYPE=33619919&amp;REALMOID=06-07701714-c347-43f8-bba0-688bac1edcb9&amp;GUID=&amp;SMAUTHREASON=0&amp;METHOD=PUT&amp;SMAGENTNAME=$SM$UKW4i11am9L5ITf0sVmE1loiw%2fpQcyWDPqnx2hsNNj1Re%2b4px5Mi%2fn2us1OBlwhZ&amp;TARGET=$SM$https%3a%2f%2fitssp-gl3-xyz%2enet%2fabc%2fapi%2f1%2e0%2ftest%2f126">here</a>.</p>
</body></html>

Solution

  • You would have to make a POST request directly to the fcc url.

    Typically the below params are needed:

    1. USER
    2. PASSWORD
    3. TARGET
    4. AGENT

    There are some static parameters also that you may need to send. You can get the list of params by opening the URL in the browser and seeing what parameters are sent when the login page is submitted (use HttpFox/FireBug/Fiddler etc.)

    The response would be a 302 Redirect with a Set-Cookie header SMSESSION. If you are able to use this cookie in the requests that you make to the REST service you will stop getting the redirects.

    However if you are building a decent sized application, you may want to look at using the SM 12.5 feature of Authentication services. That allows you to get a SMSESSION cookie as a response to SOAP/REST service call to SiteMinder.