Home

Awesome

CouchDB OAuth example

Build Status Dependency Status devDependency Status

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:

  1. Spins up a CouchDB server using MultiCouch.
  2. Configures CouchDB server to store OAuth credentials in _users database.
  3. Creates a user with OAuth credentials in its user document.
  4. Sends request to CouchDB server using OAuth to prove authentication works.
  5. 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