CouchDB User Manager App

Using Futon to manage CouchDB users is fairly straightforward. There’s a few caveats when adding a new user or adding roles to a user or changing a user’s password.  So, I set out to create a CouchApp to help manage users through a basic interface.  The source is available on GitHub


The CouchDB User Manger app is a single HTML file attached to a CouchDB document. I created a document called “user_admin” in a database called “loveseat” and attached the HTML file there.  The URL to the app is For testing purposes, I left this document open to the public. However, in a production environment a document validation function should be used to prevent the public from modifying the attachment and roles should be assigned to allow read-only access to the database.

Aside from attaching the HTML file to a document, there is one other changes required in CouchDB.  A design view is required to “emit” user information to the application.

Designing a View

In order to prevent unnecessary access to  data in the _users database, I created a view that only reveals the following user details: _id, _rev, roles and name. The view also does not transmit details regarding the user “admin.”

function(doc) {
var key;
if( != “admin”){
key = [doc._id, doc._rev, doc.roles];

Here is what the view looks like in Futon.

Create the listForSelect design view in _users.
Create the listForSelect design view in _users.


About the App

After the attachment and the listForSelect view is in place, you should be able to access the CouchApp. The page logs out the current user each time it is loaded. So, even if you are logged into CouchDB when you access the page, you will be logged out and prompted to log in.

Login page for CouchDB User Admin app
Login page for CouchDB User Admin app

After logging into the app, the create, update and delete interface is presented. The select lists are dynamically refreshed when a new user is added or delete via the tool. Updates do not refresh the select options. In the update section, roles are populated based on the user selected.

Screenshot of CouchDB User Admin app
CouchDB User Admin app



There’s still some work to be done. Specifically, improved error handling and alerting the user to session timeout before data is submitted.

Check out the source on github and let me know if you have any questions or suggestions.

Link to source on github:


Leave a Reply