Couchbase sync_gateway open to everybody

Hello!

What is the best approach to have a database open to all peoples using mobile apps? I want to let free access READ ONLY to all mobile users without authentication for some database. I also need a way to sync this database - all documents. I plan to “post” the documents trough nodejs -> sync_gateway rest api and only read/sync them from mobile and web devices.

Best Regards

So if I understand correctly, you want to make a read-only sync gateway? I believe there is an example of that on this page

The sync function in the example throws an exception for any write attempts, thus making the sync gateway read only.

The problem with that config is that it disallows ALL writes, so you can’t even get the data into the Sync Gateway as an admin.

What you want can be accomplished but it’s not as straightforward as I’d like to to be. First you need a sync function like this:

function(){
  requireUser("no-one-here")
}

This function will allows writes into the admin port, but not via the regular port. If a user were to sign up with the user id “no-one-here” they’d be able to write. So to block that you can create a user with that name and an unguessable password in the same config file as the sync function. Something like you see here:

...
"users" : {
  "no-one-here" : {
    "password" : "lkjhafsdlkjhsadflkjh"
  }
},
...