myCRM/bruno/README.md
olli 1e02439e8a feat: Implement project ownership and team member management with access control
- Added owner and team members relationships to the Project entity.
- Updated ProjectRepository to find projects based on user ownership or team membership.
- Enhanced ProjectVoter to manage view, edit, and delete permissions based on ownership and team membership.
- Created ProjectAccessExtension to filter projects based on user access.
- Updated ProjectManagement.vue to include owner and team member selection in the UI.
- Implemented API endpoints for managing Git repositories with proper access control.
- Added migration to update the database schema for project ownership and team members.
2025-11-14 10:49:54 +01:00

149 lines
3.6 KiB
Markdown

# myCRM Bruno API Collection
Diese Bruno-Collection enthält alle API-Endpunkte für die myCRM-Anwendung.
## Setup
1. **Bruno installieren**
```bash
# Via npm
npm install -g @usebruno/cli
# Oder Desktop-App von https://www.usebruno.com/ herunterladen
```
2. **Collection öffnen**
- Bruno Desktop-App öffnen
- "Open Collection" wählen
- Diesen `bruno/` Ordner auswählen
3. **Environment konfigurieren**
- In Bruno: Environment "local" auswählen
- Session-Cookie holen:
```bash
# Option 1: Aus Browser DevTools kopieren
# 1. In Browser bei localhost:8000 einloggen
# 2. DevTools → Application → Cookies
# 3. PHPSESSID kopieren
# Option 2: Via Symfony CLI
symfony server:log
# Nach Login den Cookie aus den Logs kopieren
```
- In `environments/local.bru` den `sessionCookie` Wert eintragen
## Verfügbare Sammlungen
### Git Integration
Alle Endpunkte für die Git-Repository-Integration:
- **Get Git Repositories** - Liste aller Repositories eines Projekts
- **Get Single Repository** - Details eines einzelnen Repositories
- **Test Repository Connection** - Verbindung testen (10 Commits)
- **Get Commits** - Commit-Historie abrufen
- **Get Contributions** - Tägliche Contributions für Heatmap
- **Refresh Cache** - Cache manuell leeren
- **Create Repository** - Neues Repository anlegen
- **Update Repository** - Repository aktualisieren
- **Delete Repository** - Repository löschen
## Authentifizierung
Die API verwendet Session-basierte Authentifizierung:
```
Cookie: PHPSESSID=your_session_id_here
```
Die Session wird automatisch von allen Requests verwendet, wenn sie im Environment konfiguriert ist.
## Sicherheit
Alle Endpunkte sind durch Symfony Security und Voter geschützt:
- **Authentication**: Session-Cookie erforderlich
- **Authorization**: GitRepositoryVoter prüft VIEW/EDIT/DELETE Rechte
- **Project-Filtering**: Nur Repositories des eigenen Projekts sind sichtbar
## Caching
Die Git-Integration verwendet Symfony Cache:
- **Commits**: 15 Minuten (900s)
- **Contributions**: 1 Stunde (3600s)
- **Manuelles Löschen**: POST `/api/git-repos/{id}/refresh-cache`
## Provider-Typen
### GitHub
```json
{
"provider": "github",
"owner": "username",
"repo": "repository",
"personalAccessToken": "ghp_xxxxx"
}
```
### Gitea
```json
{
"provider": "gitea",
"owner": "username",
"repo": "repository",
"personalAccessToken": "gitea_token",
"giteaUrl": "https://gitea.example.com"
}
```
### Local
```json
{
"provider": "local",
"localPath": "/absolute/path/to/repo"
}
```
## Testing
1. **Repository-Verbindung testen**:
```
POST /api/git-repos/{id}/test
```
2. **Commits abrufen**:
```
GET /api/git-repos/{id}/commits?branch=main&limit=50
```
3. **Contributions für Heatmap**:
```
GET /api/git-repos/{id}/contributions?branch=main&year=2025
```
## Troubleshooting
### 401 Unauthorized
- Session-Cookie abgelaufen → Neu einloggen und Cookie aktualisieren
- Cookie falsch formatiert → Format: `PHPSESSID=value`
### 403 Forbidden
- Voter verweigert Zugriff → Repository gehört nicht zum eigenen Projekt
- Fehlende Berechtigungen → Projekt-Zugriff prüfen
### 404 Not Found
- Repository existiert nicht
- Falsche ID verwendet
- Repository wurde gelöscht
### 500 Internal Server Error
- Git-Fehler → Repository-Einstellungen prüfen (owner/repo/branch)
- Token ungültig → Personal Access Token erneuern
- Cache-Fehler → `var/cache/` Ordner prüfen
## Weitere Informationen
- [Symfony API Platform Docs](https://api-platform.com/)
- [Bruno Documentation](https://docs.usebruno.com/)
- [Git Integration Docs](../docs/GIT_INTEGRATION.md)