-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add communityMetadata store validation #1891
Comments
Whoever tackles this should dig into it a bit and write up a document proposing how to solve the problem and get feedback before they start writing code. Part of the complexity is that you need to know the owner's OrbitDB ID or something about the owner to have some sense of truth here. |
In order to only allow the community owner to edit community metadata, we need to know if an entry was written by the community owner. To do this we can use the OrbitDB identity ID as OrbitDB uses to verify write permissions in OrbitDB's IPFSAccessController: https://github.com/orbitdb/orbit-db-access-controllers/blob/3741eb318e9c7efea5af15a54110cf6de8ae1fe3/src/access-controllers/ipfs.js#L20. Since each member of the community will need to know this ID in order to validate community metadata entries, we can simply include the community owner's OrbitDB identity ID in the invite link. After the owner initializes their OrbitDB databases for the first time, we can save their identity ID (orbitdb.identity.id) in LevelDB under a key like The owner's identity ID should be sent to the frontend for incorporating it into the invite link. In order to include the owner's OrbitDB identity ID and a PSK (#1897) in the link, we will need to reduce the number of peers in the invite link by 1. So PSK + owner OrbitDB identity ID + 3 peers. When a new user clicks that link and joins, the owner's identity ID should be parsed from the invite link and sent to the backend where it's stored in LevelDB (via the same interface defined in The community metadata DB stores the owner's public key, which we use for authentication in some instances (e.g. when checking cert validity). So we should wait until community metadata has been replicated before initializing other OrbitDB databases (or at least those that depend on the owner's cert). As for community metadata validation, it looks like access controllers only validate heads and not each entry. So instead of using an access controller, we can simply validate each entry ourselves. We can create a new validation function in the backend In order to validate entries in an EventStore, it's fairly straightforward as discussed in #1893. However, communityMetadata is currently a key/value store. Since we don't support multiple communities yet, I'm not sure we benefit from using a key/value store in this case, but we can continue with that approach to reduce refactoring. For KeyValueStore databases, the interface does not include an iterator method, so we can create our own KeyValueIndex (https://github.com/orbitdb/orbit-db-kvstore/blob/main/src/KeyValueIndex.js) class with a custom updateIndex method to filter log values with Then we can create a new function, I think it would be nice to encapsulate this logic in a |
2.0.3-alpha.15 Done |
Only the owner should be able to update the community metadata. Currently anyone can modify the community metadata. This allows anyone to change the owner certificate (and nickname) and community name.
As an example, we replicate community metadata here:
quiet/packages/backend/src/nest/storage/storage.service.ts
Lines 244 to 248 in 277f966
We save the metadata to the Redux store:
quiet/packages/state-manager/src/sagas/socket/startConnection/startConnection.saga.ts
Lines 263 to 271 in 277f966
We get the owner nickname from ownerCertficate:
quiet/packages/state-manager/src/sagas/communities/communities.selectors.ts
Line 78 in 277f966
Which is used to send a channel message:
quiet/packages/state-manager/src/sagas/publicChannels/createGeneralChannel/sendInitialChannelMessage.saga.ts
Line 20 in 277f966
Another example, we set the community name from communityMetadata.rootCa:
quiet/packages/state-manager/src/sagas/communities/updateCommunity/updateCommunity.saga.ts
Line 6 in 277f966
which is displayed to the user in the left-side panel:
quiet/packages/desktop/src/renderer/components/Sidebar/IdentityPanel/IdentityPanel.tsx
Line 49 in 277f966
The text was updated successfully, but these errors were encountered: