Hi guys,
Can I have a quick solution for this,
In the CouchBase server, I have these three types of documents
And in the sync gateway, I’ve created a test user (username=firstUser, password=123) using “CURL” command. And the user has created successfully.
_sync:user:firstUser
{
“name”: “firstUser”,
“all_channels”: {
“!”: 1,
“public”: 4,
“user-firstUser”: 4
},
“sequence”: 5,
“passwordhash_bcrypt”: “JDJhJDEwJDVMLmppN0FVcU9OdWhqUnRkYWRHcnVRVy91WkhQc2E2UGtFclMuRUlxVnR4bzhmYjBtNVZD”,
“rolesSince”: {}
}
And in the Client app, I used basic HTTP auth with username and password of test user,
Authenticator auth = AuthenticatorFactory.createBasicAuthenticator(“firstUser”, “123”);
pushReplication.setAuthenticator(auth);
pullReplication.setAuthenticator(auth);
Initially, client app had no data in local database, what I wanted to do was to pull above 3 documents to the local database.
The Profile document is private to the user, so I needed to pull that user specific profile document only. (there will be many Profile type documents for different users)
And other two documents (Person and Group) are public, that is any user can pull them to their local db.
So I used the following SGW configuration, I’ve disabled the guest access.
{ "adminInterface": "127.0.0.1:4985", "interface": "0.0.0.0:4984", "log":["REST"], "databases":{ "eegbase":{ "server":"http://localhost:8091", "sync":`function(doc) { if(doc.type="Group"){ channel("public"); } if(doc.type="Person"){ channel("public"); } if(doc.type="Profile"){ requireUser(doc.userName); channel("user-"+doc.userName); access(doc.userName, ["user-"+doc.userName,"public"]); } }', "users":{ "GUEST":{"disabled":true,"admin_channels":["*"]} }, "shadow": { "server": "http://localhost:8091", "bucket": "eegbase_backend" } } } }
Problem is, I only receive the “Profile” document. Other two documents are not replicated to the local database. Why is that? Am I using a wrong configurations? (It worked with no user authentication and guest access)
My terminal window shows following commands
13:34:51.750691 HTTP: #001: GET /eegbase/_session (as firstUser)
13:34:51.761001 HTTP: #002: GET /eegbase/_session (as firstUser)
13:34:51.780034 HTTP: #003: GET /eegbase/_local/fcddf639dd77f7af379546c8ca43d8700af58292 (as firstUser)
13:34:51.780274 HTTP: #003: --> 404 missing (0.7 ms)
13:34:51.780676 HTTP: #004: GET /eegbase/_local/9aee9f892cb6afc2cd71784244f6daa8c00083bf (as firstUser)
13:34:51.780797 HTTP: #004: --> 404 missing (0.6 ms)
13:34:51.796580 HTTP: #005: GET /eegbase/_session (as firstUser)
13:34:51.803773 HTTP: #006: GET /eegbase/_local/fcddf639dd77f7af379546c8ca43d8700af58292 (as firstUser)
13:34:51.803892 HTTP: #006: --> 404 missing (0.4 ms)
13:34:51.857694 HTTP: #007: POST /eegbase/_changes (as firstUser)
Thanks
-Isuru