开发者

openID in wsgi with Python 3

I have never done authentication stuff before, but would like to be able to track and authenticate users via openID. I saw a couple modules that allow for openID authentication with WSGI, but all are old and none mention python3, so I'm guessing they do not work.

I'd like some suggestions as to how to handle/authenticate openID in WSGI and python3. A simple implementation开发者_如何学Python would be appreciated.


Two caveats on this answer right away:

  • I've you're well versed in your framework, urllib and it's friends, implementing this will still take a bit of time. It's not trivial.

  • The openid2rp code doesn't look all that, uhm, ready.

None the less. The latest version of openid2rp can be translated with 2to3 to work in Python 3. You will need to fix a couple of small things.

The included example code won't work, but you can use it as a template to write your application. If you're careful about bytes vs. strings, it should take less than two years to get a working OpenID login. (:

I've managed to translate it into cherrypy this way. While that's not what you're looking for, it might be a helpful guide: http://paste.ubuntu.com/699338/

As an example, this kind of code still remains after running 2to3:

- mac_key = base64.decodestring(session['mac_key'])
+ mac_key = base64.b64decode(session['mac_key'].encode())

You'll see these things as you write the actual login-code.

This is my __init__.py. Note that the methods I don't yet use still have bugs! http://paste.ubuntu.com/699354/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜