简体   繁体   English

Python 具有 CAS 身份验证的 RESTful 客户端

[英]Python RESTful client with CAS authentication

I'm trying to build a python library for interacting with our RESTful API, but it uses CAS for client auth, and I haven't been able to find any good existing libraries for it.我正在尝试构建一个 python 库来与我们的 RESTful API 进行交互,但它使用 CAS 进行客户端身份验证,而且我还没有找到任何好的现有库。 So far I've found the following links, but I'm not sure if they're intended to be used in clients or by a website that uses CAS itself.到目前为止,我已经找到了以下链接,但我不确定它们是用于客户端还是由使用 CAS 本身的网站使用。 Does anyone have any advice for a good library to use and a good way to structure my code for interacting with it?有没有人对使用好的库以及构建代码以与之交互的好方法有任何建议?

https://wiki.jasig.org/download/attachments/28213515/pycas.py.txt https://wiki.jasig.org/download/attachments/28213515/pycas.py.txt

https://sp.princeton.edu/oit/sdp/CAS/Wiki%20Pages/Python.aspx https://sp.princeton.edu/oit/sdp/CAS/Wiki%20Pages/Python.aspx

http://github.com/benoitc/restkit/ http://github.com/benoitc/restkit/

http://morethanseven.net/2009/02/18/python-rest-client.html http://morethanseven.net/2009/02/18/python-rest-client.html

I also just tried using caslib , but that fails to work:我也刚刚尝试使用caslib ,但是没有用:

>>> import caslib
>>> srv = caslib.CASServer('https://my.cas/auth')
>>> svc = caslib.CASService('https://my.service/foo')
>>> caslib.login_to_cas_service(srv.login(svc),'user@example.com','password')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "caslib/cas_dance.py", line 250, in login_to_cas_service
    raise CASLoginError('Could not parse the document at %s: %s' % (login_fh.url, errors))
caslib.cas_dance.CASLoginError: Could not parse the document at https://my.cas/auth/login?service=https%3A%2F%2Fmy.service%2Ffoo: undefined entity &copy;: line 97, column 26

Hmm, the error above appears to be in our markup (or the validater that caslib uses.)嗯,上面的错误似乎在我们的标记中(或 caslib 使用的验证器。)

Edit again: The failure is removed after installing the lxml library for python. The fallback parser didn't work as well.再次编辑:为 python 安装 lxml 库后,故障被移除。回退解析器也没有工作。

您可能需要推出自己的解决方案,方法是修改python rest客户端以支持CAS,或者从头开始构建一些东西(我建议在httplib2之上)。

Eleven years later, there are at least two Python CAS libraries, with Flask examples available:十一年后,至少有两个 Python 个 CAS 库,可用的示例有 Flask 个:

python-cas - seems more current python-cas - 似乎更流行
Flask-CAS -- Github repo gone Flask-CAS -- Github repo 不见了

I don't personally have these working yet, so YMMV.我个人还没有这些工作,所以 YMMV。

也许是以下官方Python示例: https//wiki.jasig.org/display/casum/restful+api

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM