Documentation Index
Fetch the complete documentation index at: https://mintlify.com/estebanrfp/gdb/llms.txt
Use this file to discover all available pages before exploring further.
GenosDB SM ACLs Module
Overview
The Access Control Lists (ACLs) module provides fine-grained, node-level permissions for GenosDB. Unlike role-based access control (RBAC) which applies global permissions, ACLs allow you to control access to individual nodes, enabling collaborative applications where different users can have different permissions on specific data.Key Features
- Node-Level Permissions: Grant/revoke permissions per user per node
- Flexible Permission Types:
read,write,delete - Owner-Based Control: Node creators are automatically owners with full permissions
- Real-Time Synchronization: Permission changes sync across all peers
- Integration with RBAC: Works alongside existing role-based permissions
- Automatic Middleware: Enforces permissions on all database operations
How permissions work
Quick Start
1. Enable ACLs
2. Create a Node with ACLs
3. Grant Permissions
4. Check Permissions in Your App
API Reference
db.sm.acls.set(value, id?)
Creates or updates a node with ACL protection.
Parameters:
value(object): The data to storeid(string, optional): Node ID. Auto-generated if not provided
Promise<string> - The node ID
Example:
db.sm.acls.grant(nodeId, userAddress, permission)
Grants a permission to a user for a specific node. Only the owner can grant permissions.
Parameters:
nodeId(string): The node IDuserAddress(string): Ethereum address of the userpermission(string):'read','write', or'delete'
Promise<void>
Example:
db.sm.acls.revoke(nodeId, userAddress)
Revokes all permissions from a user for a specific node. Only the owner can revoke permissions.
Parameters:
nodeId(string): The node IDuserAddress(string): Ethereum address of the user
Promise<void>
Example:
db.sm.acls.delete(nodeId)
Deletes a node. Only the owner can delete their nodes.
Parameters:
nodeId(string): The node ID to delete
Promise<void>
Example:
db.sm.acls.getPermissions(nodeId)
Gets the permission structure for a node.
Parameters:
nodeId(string): The node ID
Promise<{owner: string, collaborators: object}>
Example:
Permission Types
read
- Allows viewing the node’s value and edges
- Required for
db.get(nodeId)operations - Does not allow modifications
write
- Includes
readpermissions - Allows updating the node’s value with
db.sm.acls.set() - Allows creating edges to/from the node
delete
- Includes
readandwritepermissions - Allows deleting the node with
db.sm.acls.delete() - Note:
deletepermission is not automatically granted withwrite
Integration with RBAC
ACLs work alongside GenosDB’s Role-Based Access Control system:- RBAC Check: User must have the required role permission
- ACL Check: If RBAC passes, ACL permissions are checked
- Operation: Only executes if both checks pass
Real-World Examples
Collaborative Document Editor
Task Management System
Security Considerations
Owner Privileges
- Automatic Ownership: Node creators become owners with full permissions
- Owner-Only Operations: Only owners can grant/revoke permissions and delete nodes
- No Self-Revocation: Owners cannot revoke their own permissions
Permission Validation
- Middleware Enforcement: All operations are validated through ACL middleware
- Real-Time Checks: Permissions are checked before each operation
- Cryptographic Verification: Operations are signed and verified by all peers
- Enforced against malicious peers (since 0.14.0): incoming operations are checked in
verifyIncomingOperationsagainst the cryptographically-verified author, so a modified peer cannot write a node it does not own — even by bypassing the UI
Best Practices
- Validate Permissions Client-Side: Always check permissions before showing UI controls
- Handle Permission Errors: Gracefully handle cases where users lose permissions
- Use Appropriate Permissions: Grant minimal required permissions
- Monitor Access Patterns: Log permission changes for security auditing
- Regular Cleanup: Periodically review and revoke unnecessary permissions
Troubleshooting
Common Issues
“No write permission” Error- Ensure
rtc: trueis enabled - Check that all peers are connected
- Verify user addresses are correct (case-sensitive)
- Owner is set at creation and cannot be modified
- To transfer ownership, create a new node and grant permissions
Migration from Manual Permission Checks
If you’re currently using manual permission checks:Performance Notes
- Minimal Overhead: ACL checks are performed only when necessary
- Cached Results: Permission checks use cached node data when available
- Efficient Queries: Use indexed queries to filter accessible nodes
- Batch Operations: Group permission checks to reduce network calls
Browser Compatibility
- Modern Browsers: Full support for all features
- HTTPS Required: WebAuthn requires secure context
- P2P Support: WebRTC-enabled browsers for real-time sync
- Storage: OPFS support for persistent storage
For more examples and advanced usage, see the testbed implementation in the examples directory.