I reached syncronization doing insert/update/delete in couchbase lite on an item using its id.
With no sync function in json gateway config file , with no channels specified in doc , i reached anyway syncronization. If 2 devices are able to know this id (uuid) i can reach syncronization.
I work with same item using its id and sync is granted anyway.
Is this a good way to sync items?
What does the entire config file look like?
It sounds like you’ve got the example entry for a ‘GUEST’ user with access to ‘*’. This gives anyone access to all documents without authentication. Useful for getting started, but of course not for real deployment.
You are right. But suppose i’m able from a device to share (by email) this id with another device i can do query and or update on this id item and sync is granted with no sync func. Right?
{
“log”: ["*"],
“CORS”: {
“Origin”: [
“string”
],
“LoginOrigin”: [
“string”
],
“Headers”: [
“string”
],
“MaxAge”: 0
},
“databases”: {
“db”: {
"unsupported": {
"user_views": {
"enabled":true
}
},
"server": "http://localhost:8091/",
"bucket": "default",
"users": { "GUEST": { "disabled": false, "admin_channels": ["*"] } }
}
}
}
A sync function is essential for data validation, for enforcing access control and data routing in order to ensure that documents are only accessible only to authorized users. Basically, it enforces the security in the system.
If you don’t provide a sync function, the Sync gateway will use a default one which essentially grants all users unrestricted access to all documents. That is why you are able to access the document from both the devices as a guest user even if you don’t provide an explicit sync function. Thats because the document is automatically synched to all the devices.
The default sync function is expected to be used only for testing and is undesirable in production environments. Moreover, as noted above, granting unrestricted guest mode access is probably not what you need in your prod environment.
You may want to check out the sync function docs at https://developer.couchbase.com/documentation/mobile/1.4/guides/sync-gateway/sync-function-api-guide/index.html