Search code examples
curlcas

Logging on to CAS server through cURL


I am trying to login to a CAS server using cURL. Here is where I am so far.

I grabbed the authentication page and replaced POST with GET to see what my fields are.

file:///cas/login;jsessionid=89C2DA1B80B0C4E812F2D09CC01C05DB?username=&password=&lt=LT-2960-zIS6pxYZHdsBX7IkykfbW14oLJhdNL&execution=e1s1&_eventId=submit&submit=LOGIN

so I run

curl -k --cookie-jar dump --data "jsessionid=89C2DA1B80B0C4E812F2D09CC01C05DB?username=&password=&lt=LT-2960-zIS6pxYZHdsBX7IkykfbW14oLJhdNL&execution=e1s1&_eventId=submit&submit=LOGIN" https://CASHOST/cas/login > output

(filling out the username, password, and CASHOST obviously)

But my output is blank. If I remove the jsessionid field its also blank.

Something that is worrying me is the jsessionid field because its constantly changing.

Any ideas?


Solution

  • Please use curl -v. Probably you are getting 302 redirect to the login page.

    I am using adopted https://gist.github.com/dodok1/4134605 which works fine for me, and maybe will work better for you.

    All it needed was to add &execution=e1s1 to the call which passes the password to CAS.

    My working solution is here: https://gist.github.com/gkazior/4cf7e4c38fbcbc310267