sprint1: set_user_context + RLS policies on contacts + folder ACL migration 0051+0052

This commit is contained in:
Agent Zero
2026-07-29 01:30:25 +02:00
parent 5afa1fa927
commit 48647a58e0
5 changed files with 210 additions and 36 deletions
+35 -35
View File
@@ -1,6 +1,6 @@
# RBAC Build Progress — LeoCRM
## Letztes Update: 2026-07-29 01:23 CEST
## Letztes Update: 2026-07-29 01:28 CEST
## Sprint 1 — Fundament (14h)
@@ -18,14 +18,38 @@
- Index auf owner_id
- Kann auf jedes Model angewendet werden
- [x] Migration 0049: entity_permissions Tabelle — ✅ Ausgeführt in Produktion
- [x] Migration 0050: owner_id auf 15 Tabellen — ✅ Ausgeführt in Produktion
- [x] OwnedMixin auf alle 13 Models angewendet:
- Contact, Address, Attachment, BankAccount, Workflow, Sequence
- SavedFilter, SavedView, Webhook, Notification, CustomFieldDefinition
- EntityHistory, AIConversation
- [x] Universeller Permission Service (`app/services/entity_permission_service.py`, 648 Zeilen)
- list_permissions, create_permission, update_permission, delete_permission
- get_effective_access (Owner → User → Group → Role → None)
- get_visible_ids (alle sichtbaren Datensätze für User)
- batch_get_effective_access (Batch-Resolution für Listen)
- get_cached_visible_ids (Redis Cache, 5 Min TTL)
- check_entity_access (einfacher Check)
- cleanup_expired_permissions (Background Worker)
- [x] Universelle Permission API (`app/routes/entity_permissions.py`, 151 Zeilen)
- GET /api/v1/permissions/{entity_type}/{entity_id}
- POST /api/v1/permissions/{entity_type}/{entity_id}
- PUT /api/v1/permissions/{entity_type}/{entity_id}/{permission_id}
- DELETE /api/v1/permissions/{entity_type}/{entity_id}/{permission_id}
- GET /api/v1/permissions/{entity_type}/{entity_id}/access
- GET /api/v1/permissions/registry
- [x] Schema erstellt (`app/schemas/entity_permission.py`)
- [x] Route in main.py registriert
- [x] Alle Imports getestet — OK
- [x] Container neu gestartet
- [x] Git committed und gepusht (5afa1fa)
### In Bearbeitung 🔄
- [ ] Migration 0049: entity_permissions Tabelle
- [ ] Migration 0050: owner_id auf allen Models
- [ ] OwnedMixin auf alle Models anwenden
- [ ] EntityPermission in models/__init__.py registrieren
- [ ] Universeller Permission Service
- [ ] Universelle Permission API (5 Endpoints)
- [ ] Redis-Cache für Entity-Permissions
- [ ] PostgreSQL RLS Policies + set_user_context()
- [ ] Rate Limiting auf Permission-Änderungen
- [ ] Folder ACLs migrieren (Migration 0051)
@@ -35,40 +59,16 @@
---
## Modelle erstellt in dieser Session
| Datei | Beschreibung |
|-------|-------------|
| app/models/entity_permission.py | Universelle ACL-Tabelle für alle Entities |
| app/models/owned_mixin.py | Mixin für owner_id auf jedem Model |
| app/models/contact_folder_permission.py | Folder-spezifische Permissions (wird migriert) |
## Services erstellt in dieser Session
| Datei | Beschreibung |
|-------|-------------|
| app/services/contact_folder_permission_service.py | Folder Permission Service (wird migriert) |
## Routes erstellt in dieser Session
| Datei | Beschreibung |
|-------|-------------|
| app/routes/contact_folder_permissions.py | Folder Permission CRUD API |
## Frontend erstellt in dieser Session
| Datei | Beschreibung |
|-------|-------------|
| frontend/src/components/contacts/FolderPermissionDialog.tsx | Permission Dialog UI |
| frontend/src/api/contactFolders.ts | Folder Permission API + Typen |
| frontend/src/api/contacts.ts | Folder Permission Hooks |
| frontend/src/components/contacts/ContactFolderTree.tsx | Menu-Eintrag 'Rechte' integriert |
## Migrationen
| # | Beschreibung | Status |
|---|-------------|:---:|
| 0048 | contact_folder_permissions Tabelle | ✅ Ausgeführt |
| 0049 | entity_permissions Tabelle | ⬜ Geplant |
| 0050 | owner_id auf allen Tabellen | ⬜ Geplant |
| 0049 | entity_permissions Tabelle | ✅ Ausgeführt |
| 0050 | owner_id auf 15 Tabellen | ✅ Ausgeführt |
| 0051 | Folder ACLs → entity_permissions | ⬜ Geplant |
## Git Commits
| Hash | Beschreibung |
|------|-------------|
| cc021cd | feat: folder permissions (ACLs) - share folders with users/groups |
| 5afa1fa | sprint1: entity_permissions table + owned_mixin + universal permission service + API + migrations 0049+0050 |