Update ACCESS_CONTROLLERS.md

included comments
This commit is contained in:
Karsten Ohme 2024-01-26 04:02:58 +01:00 committed by GitHub
parent 9a5ca21577
commit 7001c7528b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -103,8 +103,6 @@ Grant and revoke are not limited to 'write' access only. A custom access capabil
The OrbitDBAccessController is a mutable access controller. Granting and revoking access does not change the address of the database.
The identities are synced using IPFS, hence also the IPFS instance must passed as in `Identities({ ipfs })`.
## Custom Access Controller
Access can be customized by implementing a custom access controller. To implement a custom access controller, specify:
@ -164,6 +162,21 @@ const canAppend = async (entry) => {
In the above example, the `entry.identity` will be the hash of the identity. Using this hash, the entire identity can be retrieved and the identity's id is used to verify write access. `write.includes('*')` is wildcard write and would allow any identity to write to the operations log.
The Identities getIdentity function will fetch the identity from the Identities storage, requesting it from the remote peer if it is not available locally. To synchronize identities across peers, IPFSStorage must be used. To enable IPFSStorage for Identities, pass either an instance of IPFS or an IPFS-enabled storage to the Identities function.
To pass IPFS to Identities:
```
const identities = await Identities({ ipfs })
```
To pass IPFS-enabled storage:
```
const storage = await IPFSStorage({ ipfs })
const identities = await Identities{{ storage })
```
### Using a custom access controller with OrbitDB
Before passing the custom access controller to the `open` function, it must be added to OrbitDB's AccessControllers: