Per request, I ported Filipe's oauth users db code from ubuntuone to couch. In the attached zip (oauth_uses_db_patch.zip) is an updated couch_httpd_oauth.erl, a .patch of the changes, and a test file called oauth_users_db.js.
What this code is: Filipe's code, with the ubuntuone specific delegation stuff stripped out. My Erlang fu is still pretty weak, so I may have done slightly naive stuff. Filipe: if you'd give it a once over to make sure nothing looks too terrible, I'd appreciate it.
Note: I was having a hard time getting the new spidermonkey to compile on my box (OSX Snow Leopard). If anybody has any pointers to useful tips on getting it to work, I'd really appreciate them, too. Since there aren't any differences between trunk and 1.1.x in couch_httpd_oauth.erl, I went ahead and wrote and tested this against 1.1.x. It should work just fine in trunk. I'm going to work on getting trunk to compile to make doubly sure, but since the code very probably works just fine, I wanted to get it posted here, without further delay.