CASを通過するためにPythonを利用している人々の例は見つかりませんでした。ケネス・ライツが「リクエスト」でこれを簡単にする方法を教えてくれることを願っています...
基本的に、CASログインを通過できません...Pythonの試行を認証しません。(2つのURLを定義しました... url1はメインのWebページであり、url2はCASサイトへのリダイレクトリンクです...私はすでにリダイレクトリンクを知っているので、簡単にできます)。
私がしなければならないのは、CASから送信されたJsessionIdをCookieとしてキャプチャし、そのCookieを取得してURLにjsessionidを追加し、ユーザー名/パスワードを使用してPOSTとしてCASに送信することだけです。 )。ただし、このスクリプトは毎回失敗します。
一部のCASの達人が私を助けてくれますか?なぜそれが私を認証しないのか理解できません。
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
出力....jsessionIdがurl2に追加される方法に注意してください。これは良いことです.....私は思います。
{'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">
<!-- Congratulations on bringing CAS online! The default authentication handler authenticates where usernames equal passwords: go ahead, try it out. -->
<h2>Enter your UserId and Password</h2>
(this is just the xml of the CAS login page that I can't get past)
...
...