Context
I am using the Couchbase Lite Swift SDK, version 3.2.4 and connecting to Capella via Sync Gateway. In my App Endpoint, for each linked collection I have set this access control function:
function (doc, oldDoc, meta) {channel('!');}
As I understand it, this is the public channel and the documents in the linked collection should be available to ANY user that connects to the endpoint. But the Replicator seems to ignore the public channel entirely.
If, instead, I use the default access function (where each linked collection is assigned to a channel of the same name) and then grant the user access to those channels (either via App Role or manually), the Replicator pulls down the documents perfectly.
Starting the Replicator
Here’s an excerpt of how I configure and start the Replicator. (Again, this works perfectly fine unless I try to use the public channel):
/// Configure and initiate cloud sync.
if let syncEndpointURL: URL = config.syncEndpointURL,
let syncCredentials: SyncCredentials = config.syncCredentials
{
let endpoint = URLEndpoint(url: syncEndpointURL)
var config = ReplicatorConfiguration(target: endpoint)
config.continuous = true
config.replicatorType = .pushAndPull
config.maxAttemptWaitTime = 10
// `openCollections` is an array of `Collection`. I create them earlier via:
// `try database.createCollection(name: "foo", scope: "bar")
config.addCollections(openCollections)
switch syncCredentials
{
case .password(let username, let password):
config.authenticator = BasicAuthenticator(username: username, password: password)
case .oidc(let sessionID, let cookieName):
config.authenticator = SessionAuthenticator(sessionID: sessionID, cookieName: cookieName)
}
replicator = Replicator(config: config)
replicatorStatusToken = replicator!.addChangeListener(withQueue: parentQueue, self.handleReplicatorStatusChange(_:))
replicator!.start(reset: false)
}
Another Attempted Workaround:
I even tried explicitly specifying the public channel, like this:
var collectionConfig = CollectionConfiguration()
collectionConfig.channels = ["!"]
replicatorConfig.addCollections(openCollections, config: collectionConfig)
But that still had no effect. The Replicator refuses to pull any documents from the public channel. What have I missed?