[FIX] Fix some securiry issues

This commit is contained in:
NADAL Jean-Baptiste
2026-02-18 15:27:55 +01:00
parent 3abc6f6371
commit 039cecc4a6
15 changed files with 2179 additions and 200 deletions

View File

@@ -324,12 +324,72 @@ Authorization: Bearer <token_admin>
---
### POST /admin/upload
### GET /admin/scores/:id/files
Uploader un fichier PDF.
Récupérer l'arborescence des fichiers d'une partition.
```http
POST /admin/upload
GET /admin/scores/001/files
Authorization: Bearer <token_admin>
```
**Réponse :**
```json
{
"success": true,
"files": [
{
"name": "1",
"path": "1",
"type": "folder",
"children": [
{
"name": "cla",
"path": "1/cla",
"type": "folder",
"children": [
{
"name": "1",
"path": "1/cla/1",
"type": "folder",
"children": [
{
"name": "clarinette_sib_1.pdf",
"path": "1/cla/1/clarinette_sib_1.pdf",
"type": "file"
}
]
}
]
}
]
}
]
}
```
---
### DELETE /admin/scores/:id/files
Supprimer un fichier spécifique.
```http
DELETE /admin/scores/001/files?path=1/cla/1/clarinette_sib_1.pdf
Authorization: Bearer <token_admin>
```
**Paramètres :**
- `path` - Chemin relatif du fichier (requis)
---
### POST /admin/scores/:id/upload
Uploader un fichier PDF pour une partition.
```http
POST /admin/scores/001/upload
Authorization: Bearer <token_admin>
Content-Type: multipart/form-data
```
@@ -337,10 +397,13 @@ Content-Type: multipart/form-data
**Corps de la requête :**
```
file: <fichier_pdf>
scoreId: 102
pieceId: 1
piece: 1
instrument: cla
version: 1
key: sib (optionnel)
clef: clesol (optionnel)
variant: solo (optionnel)
part: 1 (optionnel, défaut: 1)
```
---
@@ -357,6 +420,21 @@ version: 1
---
## Lancer les tests
```bash
cd api
php tests.php
```
Les tests vérifient :
- **Auth** : Login, mauvais mots de passe, token manquant/invalide
- **Scores** : CRUD, gestion d'erreurs pour ressources inexistantes
- **Create Score with Pieces** : Création avec plusieurs parties, vérification score.ini
- **Files** : Get files tree, suppression de fichiers
---
## Lancer le serveur
```bash