couchbaselabs / react-native-couchbase-lite

Couchbase Lite binding for React Native Android & iOS
MIT License
110 stars 53 forks source link

Sync gateway user authentication #101

Open gayancharith opened 7 years ago

gayancharith commented 7 years ago

following is my sync_gateway_config.json

{
  "log": ["*"],
  "databases": {
    "db": {
      "server": "http://localhost:8091",
      "bucket": "person",
      "users": { "gayan": { "disabled": false, "password": "gayan123", "admin_channels": ["*"] } }
    }
  }
}

how can I connect to the sync gateway with this credentials. I tried following method.

ReactCBLite.initWithAuth('admin', 'pass', (url) => {
      // instantiate a new database
      var database = new manager(url, 'myapp');
      //...
    });

But it does not work. seems like it authenticates the local database.

npomfret commented 7 years ago

The admin/pass credentials are just for connecting to the local database on the device over http. To connect to the sync gateway you need follow the createDatabase example. It shows how to add the sync gateway username and password to the url.

gayancharith commented 7 years ago

@npomfret Now I have a different problem. Even I have added user credentials on the sync_gateway_config.json file which I used to run sync gateway. I can connect to sync gateway without those user credentials.

npomfret commented 7 years ago

I can connect to sync gateway without those user credentials

I'm sorry but I don't understand your question.

gayancharith commented 7 years ago

I mean even if I have set credentials on the sync gateway config file, I don't want use them when connecting to the sync gateway. That means authentication is not working in my case.

npomfret commented 7 years ago

Don't set them if you don't want them.

gayancharith commented 7 years ago

I want to authenticate sync gateway. But seems like it is not working. May be I am using authentication in wrong place. Currently I have user credentials in sync_gateway_config.json file as below.

{
  "log": ["*"],
  "databases": {
    "db": {
      "server": "http://localhost:8091",
      "bucket": "person",
      "users": { "gayan": { "disabled": false, "password": "gayan123", "admin_channels": ["*"] } }
    }
  }
}