开发者

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. 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),'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.)

Edit again: The failure is removed after installing the lxml library for p开发者_StackOverflow社区ython. The fallback parser didn't work as well.


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.)


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜