Hi,
I’m putting this out there to see if anyone else has seen this or can suggest ideas. I’ve been staring at this and running experiments for a while, and am completely stumped.
This involves my app (mac, iOS) and sync gateway - and what I see is that “access()” to channels is being (very very rarely) removed.
Background
Documents are grouped into “books”. Each book has a channel (same as doc.id), and all documents in that book belong to the channel. Each book also has an encryption key that is used to encrypt all documents associated with that book.
Now multiple users can access/sync a book and its documents by being given the encryption key. When that key is stored (in a doctype == "BookKey”), we grant access via the sync function.
if (!isDelete() && doc.type == "BookKey") {
// give the user access to this book when a BookKey record is created
// Note that "owner" here refers to the owner of THIS book key record, not
// necessarily the owner of the book who has shared the book with this user.
// So this next line grants the user (doc.owner) access to the channel (doc.book_id)
access(doc.owner, doc.book_id);
}
Books are created (along with their keys). Books are shared, which means I give you the book id and key, which you save in a BookKey document, which causes the access to be granted, and enables you to decrypt the contents.
The Problem
This works… but very very rarely, the access rights get removed to some or all books for a user. Using the sync_gateway REST interface to query the user record, I can see “all_channels” become nearly empty, when it should list all the books they created or that have been shared with them. That is - the “all_channels” list should at least contain the channels from the BookKey type records in the database at all times. Checking the database, the BookKey records are definitely there, so they haven’t been deleted.
In theory access to a channel is removed only when the document that caused that access is removed (at least that is my understanding). So the fact that those BookKey documents still exist implies the access to the channel should still be there. It isn’t. The BookKey records aren’t tombstones.
There’s no other place I know about where access channels get changed. And there is no other way to revoke access().
Has anyone else seen values in all_channels go away?
p.s. CBLite 2.8.6, Mac and iOS.
SyncGateway 2.8.3 on Ubuntu.
Many thanks for any ideas as to where I could look.
Cheers.
Paul.