I have not found examples of how people use Python to go through CAS. Here, hopefully, perhaps Kenneth Reitz can show me how “inquiries” can do this easily ...
Basically, I can't get past the CAS login ... never authenticates my Python attempt. (note that I defined two URLs .... url1 is the main web page, url2 is the redirect link to the CAS site ... I already know the redirect link, so it simplifies it).
My understanding is all I have to do is grab the JsessionId that CAS sends to me as a cookie and then take this cookie and just add jsessionid back to the url and send it back to CAS as a POST with my username Password ) However, this script fails every time.
Can some CAS gurus help me? I just can't understand why it does not authenticate me.
import sys
import requests
my_config = {'verbose': sys.stderr }
url1 = 'http://agnes:8080'
url2 = 'https://agnes:8543/irisCAS/login?service=http%3A%2F%2Fagnes%3A8080%2FirisRootWeb%2Fj_spring_cas_security_check'
response = requests.get(url1, headers=headers, verify=False)
print response.cookies
cookies = response.cookies
response = requests.post(url2, headers=headers, verify=False, config=my_config, params=cookies, auth=('username', 'password'))
print response.status_code
print response.content
OUTPUT .... SPECIFY how jsessionId is added to url2, so ok ..... I think.
{'JSESSIONID': 'EEE38382A1D5AAACA58E12433BDA0BFF'}
2012-05-18T15:04:17.668601 POST https://agnes:8543/irisCAS/login?service=http%3A%2F%2Fagnes%3A8080%2FirisRootWeb%2Fj_spring_cas_security_check&JSESSIONID=EEE38382A1D5AAACA58E12433BDA0BFF
200
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
...
...
</script>
<form id="fm1" class="fm-v clearfix" action="/irisCAS/login;jsessionid=30ABCAC79FEA5B48399053939530A608?service=http%3A%2F%2Fagnes%3A8080%2FirisRootWeb%2Fj_spring_cas_security_check&JSESSIONID=B6235434D64C5E2E6C063BA3E1C1AC43" method="post">
<div class="box fl-panel" id="login">
<h2>Enter your UserId and Password</h2>
(this is just the xml of the CAS login page that I can't get past)
...
...
source
share