Creating a user in couchGatewayConfig.json


#1

Hi,

I tried adding a user via the couchGatewayConfig.json - file like this:

{ "interface":":4984", "adminInterface":":4985", "log": ["CRUD", "REST+"], "databases": { "dict-demo": { "server": "http://127.0.0.1:8091", "bucket": "dict-demo", "users": { "TEST": {"password":"demo", "admin_channels":["*"], "all_channels":["*"]}, "GUEST": {"disabled": false, "password":"demo", "admin_channels":["*"], "all_channels":["*"]} }, "sync": `function(doc) {channel(doc.channels);}` } } }

GET and POST are both working using the GUEST user, but as soon as I add the user TEST to the .json, I can’t start the server anymore. The Error I am shown is
FATAL: Error opening database: Invalid config for user “TEST”: Invalid password – rest.RunServer() at config.go:268

Can somebody help me about this? How do I define users correctly?

Thanks.


#2

Hi there Nadine, it looks like you are trying to set up a specific user “test” that has access to all channels. This specification should be done in the sync function, so something like:

“sync”: function(doc, oldDoc) { access ("test", doc.channel_name); }

A brief overview is available here (http://docs.couchbase.com/sync-gateway/#sync-function-api), and breakdown of a usable sync function is available here (https://github.com/couchbaselabs/CouchChat-iOS/wiki/Chat-App-Data-Model).

We are working on bettering our documentation detailing the sync function and the configuration file itself, let us know if you have any additional feedback.