Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 would be appreciated.

like image 355
8steve8 Avatar asked Apr 13 '11 23:04

8steve8


1 Answers

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/

like image 115
Stefano Palazzo Avatar answered Nov 04 '22 10:11

Stefano Palazzo