Sync Gateway access login change

Using ==== Couchbase Sync Gateway/master(d41bd84) ==== I can normally access all the views I’ve found in a given server normally

I tried to update to couchbase-sync-gateway-enterprise_1.4-67_x86_64 but I cannot access any view in the server

sync_gateway.json

{
        "log": ["HTTP", "Auth"],
        "interface": ":4984",
        "adminInterface": "0.0.0.0:4985",
        "databases": {
                "bucket1": {
                        "server_walrus": "walrus:///tmp/walrus",
                        "server": "http://localhost:8091",
                        "bucket": "bucket1",
                        "sync": `function(doc) {channel(doc.channels);}`,
                        "users": {
                                "GUEST": {
                                        "disabled": false,
                                        "admin_channels": ["*"]
                                },
                                "user": {
                                        "disabled": false,
                                        "password": "password",
                                        "admin_channels": ["*", "all"]
                                }
                        }
                },
                "bucket2": {
                        "server_walrus": "walrus:///tmp/walrus",
                        "server": "http://localhost:8091",
                        "bucket": "bucket2",
                        "sync": `function(doc) {channel(doc.channels);}`,
                        "users": {
                                "GUEST": {
                                        "disabled": false,
                                        "admin_channels": ["*"]
                                },
                                "user": {
                                        "disabled": false,
                                        "password": "password",
                                        "admin_channels": ["*", "all"]
                                }
                        }
                }
        }
}

Also, although I tried to specifically map the Admin interface to a public port, it refuses to do so.

I must note that, although I’ve done some things in the server, I still miss a lot of knowledge in the usage of the server. So treat me like a total rookie

What views are you referring to? In your config file, documents are persisted in memory (that’s fine for testing/dev!) but otherwise you should connect it to Couchbase Server. The documents are then indexed by Couchbase Server and you can browse the views used by Sync Gateway in the Couchbase Server admin console https://developer.couchbase.com/documentation/mobile/current/installation/sync-gateway/index.html#connecting-to-couchbase-server.

Also, although I tried to specifically map the Admin interface to a public port, it refuses to do so.

This is intentional to prevent any remote access (not localhost) to the Admin Console. You can access it by ssh-ing on the VM where Sync Gateway is running.

James

Which configuration aspect is telling you that? I have created buckets (bucket1, bucket2) and I verify that (bucket2 is only available for testing, bucket1 is “production/read-only”) documents are well-written in the database.

I am talking about these views. Everytime I try to access them I get 403 Forbidden (unless ADMIN). Username/password cannot be wrong, as I use the same config file for both Couchbase Sync Gateways

Oh I totally misread the config file.

Are you looking to query those views over the public port of SG and so far it only on the admin port?

I have been doing that, using the version of Couchbase you see and this code:

var cradle = require('cradle');

var c = new(cradle.Connection)('https://localhost', 10443, {
        auth: {
                username: 'user',
                password: 'pass'
        },
        ca: true,
        checkServerIdentity: function (host, cert) {
                return true;
        }
});
var db = c.database('bucket1');
function get_data_info() {
	db.view('data_info/data_info', {}, function (err, docs) {
		console.log("Data Info: Request Executed.");
		if (err) {
			console.error(err);
			return;
		}
		for (var d in docs) {
			// process-logic
		}
	});
}

Old version does everything correctly.
New version only shows them when I manually run the request on the ADMIN port (but that’s not favorable).

You might need to add some config properties https://developer.couchbase.com/documentation/mobile/1.3/guides/sync-gateway/views/index.html

For the sake of the next one who will come:

Simply add:

"unsupported": {
		"user_views": {
				"enabled":true
		}
},

in every nested databases declaration in sync_config.json

1 Like