Add oauth support

Bug #824795 reported by Jason Gerard DeRose
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Microfiber
Fix Released
High
Jason Gerard DeRose

Bug Description

I wrote Microfiber as a way to force myself to really learn the CouchDB REST API, and as an excuse to write some Python3 code. But turns out Microfiber is a better fit for dmedia and Novacut than python-couchdb... so the missing piece we need is OAuth support so we can talk to desktopcouch.

One slight wrinkle is that we're trying to move all the Novacut components to Python3, but it's not clear whether there is a maintained Python3 oauth package yet. Googling found this from 2 years ago:

http://groups.google.com/group/oauth/browse_thread/thread/96ab559211e9bd10

Microfiber is currently Python3-only, but it wont be much work to make it work with Python2 also. In fact, I'm going to do this today. So as a stop gap, we could have OAuth support when using Microfiber under Python2, which means we can transition dmedia to Microfiber ASAP.

Related branches

Changed in microfiber:
status: Triaged → In Progress
assignee: nobody → Jason Gerard DeRose (jderose)
Changed in microfiber:
milestone: 0.2 → 11.09
Changed in microfiber:
status: In Progress → Fix Committed
Revision history for this message
Jason Gerard DeRose (jderose) wrote :

So after a lot of research and looking at both the Python `oauth` and `oauth2` code, I decided to see how much work it would be to implement just enough OAuth support for Microfiber to talk to desktopcouch... and turns out, it just took 37 lines, so I went for it.

This is much better for us as right now neither `oauth` or `oauth2` is actively maintained for Python3. This seems the closest:

https://github.com/simplegeo/python-oauth2/pull/51

So in the long run, these 37 lines are a lot less work that possibly maintaining Python3 oauth2, packaging it, etc. `oauth` and `oauth2` are complete OAuth solutions, but we only need a fraction of it.

Here are the said 37 lines:

http://bazaar.launchpad.net/~jderose/microfiber/oauth/view/head:/microfiber.py#L200

Revision history for this message
Michael Chang (thenewme91) wrote :

That's pretty awesome, but what happens when we want oauth support in another part of the code, say for a storage backend? ;) Not that it's necessary right this moment, but trying to look ahead a bit.

Also surprised that you wrote code to special-case Python 3[0]; I understand we need Py3 for the Skein hash / this code was Py3 first, but my general understanding is that people who want to support both 2 and 3 usually write code that works in Py2, and works in Py3 after being run through the 2to3 tool. Is there a particular reason for this?

[0] http://bazaar.launchpad.net/~jderose/microfiber/oauth/view/head:/microfiber.py#L109

Revision history for this message
Jason Gerard DeRose (jderose) wrote :

When/if we need oauth support elsewhere... I guess we'll cross that bridge when we come to it! :-) This is probably code that should be split out into a separate package eventually.

One nice thing is that for any place where we're using OAuth with the Ubuntu Single Sign On, I think this is all the OAuth functionality we need.

As far as special casing in the code, part of this is just because I haven't gotten around to playing with 2to3 (or 3to2). But the other issue is they modify the files, so AFAIK you can't easily do things like this to check that you haven't broken any tests:

  python3 setup.py test
  python setup.py test

From talking to Barry Warsaw a bit, it seems like people are now really encouraged to write for Python3 and, if needed, to use 3to2 for Python2 support.

My plan is to release Microfiber 11.09 with the special casing, supporting both Python2 and Python3, and then switch back to Python3 only (in the code) for 11.10, and use 3to2 for Python2 support. Or perhaps just drop Python2 support altogether.

What do you think?

Changed in microfiber:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.