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

发布于 2024-09-09 03:42:33 字数 1822 浏览 8 评论 0原文

我正在尝试构建一个 python 库来与我们的 RESTful API 交互,但它使用 CAS 进行客户端身份验证,而且我还没有找到任何好的现有库。到目前为止,我已经找到了以下链接,但我不确定它们是否旨在用于客户端或由使用 CAS 本身的网站使用。有人对使用一个好的库以及构建我的代码以与其交互的好方法有什么建议吗?

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

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

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

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

我也刚刚尝试使用 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),'[email protected]','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

嗯,上面的错误似乎出现在我们的标记(或 caslib 使用的验证器)中。

再次编辑:安装 lxml 库后,该故障已消除Python。后备解析器也不起作用。

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. 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. 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://sp.princeton.edu/oit/sdp/CAS/Wiki%20Pages/Python.aspx

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

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

I also just tried using caslib, but that fails to work:

>>> import caslib
>>> srv = caslib.CASServer('https://my.cas/auth')
>>> svc = caslib.CASService('https://my.service/foo')
>>> caslib.login_to_cas_service(srv.login(svc),'[email protected]','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 ©: line 97, column 26

Hmm, the error above appears to be in our markup (or the validater that caslib uses.)

Edit again: The failure is removed after installing the lxml library for python. The fallback parser didn't work as well.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

Spring初心 2024-09-16 03:42:33

您可能必须推出自己的解决方案,要么修改 python REST 客户端以支持 CAS,要么从头开始构建某些内容(我建议在 httplib2 之上。)

You might have to roll you own solution, either by modifying the python rest client to support CAS, or building something from scratch (I would recommend on top of httplib2.)

悲念泪 2024-09-16 03:42:33

十一年后,至少有两个 Python CAS 库,并提供 Flask 示例:

python-cas< /a> - 似乎更最新
Flask-CAS -- Github 存储库消失了

我个人还没有这些工作,所以YMMV。

Eleven years later, there are at least two Python CAS libraries, with Flask examples available:

python-cas - seems more current
Flask-CAS -- Github repo gone

I don't personally have these working yet, so YMMV.

深海夜未眠 2024-09-16 03:42:33

也许,官方的Python示例: https://wiki.jasig.org/display/casum /restful+api

Maybe, the official python example in: https://wiki.jasig.org/display/casum/restful+api

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文