Search code examples
authorizationcouchdbcloudantbigcouch

What role should I use to programmatically create and delete databases in Cloudant/BigCouch/CouchDB?


Cloudant, CouchDB and BigCouch all recommend creation of user specific databases as a way to implement document level access control. i.e. AliceDB will have only documents that Alice can read, BobDB will have only Bob's docs and so on.

Implementing this pattern require programmatic creation and deletion of databases. There are DB REST APIs for these, but these APIs require the caller to have serveradmin privileges. I have many other unrelated databases on the same cluster and I am concerned about handing out a userid with serveradmin privileges. (What if the client code accidentally delete my other databases?!!)

What are people doing to get around this problem? I couldn't find anything on Cloudant, CouchDB or BigCouch documentation.


Solution

  • There are a few potential options available to you:

    • Apache CouchDB 2.0 includes a couch_peruser configuration option that may be helpful.
    • You could create your own system that does the same thing as couch_peruser. This would involve creating a program which has permission to create new database and assign permissions accordingly.
    • Cloudant Envoy can provide the illusion of having a separate database per user, without the need to actually create separate databases.