TranquilMarmot
TranquilMarmot

Reputation: 2304

Allow non-admin users to created CouchDB databases

I'm using CouchDB 2.1.0 and for my use case I would like non-admin users to be able to create their own databases that they will then have write/read access to, and the ability to add other users with write/read access.

Note that this is not one database per user, which seems to be the common use case, but many user-created databases per user.

Users are being created right now by POSTing to the _users database. Authentication is being handled by CouchDB's built-in authentication.

I could create a backend service that has admin credentials that would create these databases, but I would like to avoid doing so. Reading through docs it seems like by default CouchDB only allows admins to create databases; is there a way to change this?

Upvotes: 4

Views: 764

Answers (1)

TranquilMarmot
TranquilMarmot

Reputation: 2304

Honestly, I think the only real answer here is that you'll have to make a backend service that has admin credentials that can create new databases. Kind of a bummer since one of my goals for this project was "no backend other than CouchDB".

My backend service ended up just taking a list of users that should have access to the created database, creating the database with a unique ID, and returning that ID. I then have a document in each user's DB that lists all of the DBs they have created.

Upvotes: 1

Related Questions