Awesome
CouchDB OAuth example
This repo contains an example script that aims to show how to use CouchDB's OAuth authentication. CouchDB has support for 2-legged OAuth 1.0, but do note that it does not handle the creation of OAuth credentials (consumer keys, consumer secretes, tokens and token secrets).
The script does the following:
- Spins up a CouchDB server using MultiCouch.
- Configures CouchDB server to store OAuth credentials in
_users
database. - Creates a user with OAuth credentials in its user document.
- Sends request to CouchDB server using OAuth to prove authentication works.
- Stops the CouchDB server and cleans up.
Install
git clone https://github.com/lupomontero/couchdb-oauth.git
cd couchdb-oauth
npm install
Run
npm test
This should produce output similar to:
> couchdb-oauth@1.0.0 test /Users/lupo/Documents/workspace/lupomontero/couchdb-oauth
> node index.js
{ ok: true,
userCtx: { name: 'lupo', roles: [] },
info:
{ authentication_db: '_users',
authentication_handlers: [ 'oauth', 'cookie', 'default' ],
authenticated: 'oauth' } }
Further reading
CouchDB Docs
CouchDB Mailing List Archives
- Feb 2013: Re: Help! 2-legged OAuth Example Anyone?
- Nov 2010: OAuth example