couch-persona
A Node.js server that integrated Mozilla Persona logins with Apache CouchDB, once a user has successfully authenticated with persona we create a user and a database for their use only, on a successful login this script will return the url to a couchdb database and a token used to authenticate against that instance.
Installation
couch-persona requires a CouchDB host running, preferably with CORS support enabled.
Install and start your server
$ npm install -g couch-persona$ couch-persona --host=http://127.0.0.1:5984 --username=john --password=doe
Follow the Quick Setup instructions on the MDN wiki to install the persona client on your site, ensure you use the correct urls to sign in and out (/persona/sign-in
+ /persona/sign-out
). Here is some example working code:
// Host that the couch-persona server is running onvar authHost = 'http://127.0.0.1:3000'; var { console; // result.dbUrl is the location of your CouchDB Instance // result.authToken is the token you need to be able to write to it, // use xhr.setRequestHeader("Cookie", result.authToken);}; var { console;}; { return { if xhrreadyState == 4 if xhrstatus == 200 var result = {}; try result = JSON; catche {} ; else ; navigatorid; };} { var xhr = ; var param = 'assert=' + assertion; xhr; xhr; xhr; xhr; xhr; xhronreadystatechange = ; } { var xhr = ; xhr; xhr; xhronreadystatechange = ; } navigatorid; var signinLink = document;var signoutLink = document;signinLink { navigatorid; };signoutLink { navigatorid; };