From 01856b147caa7a8d3d832ed11de04c06bbd9e8df Mon Sep 17 00:00:00 2001 From: Matthieu Date: Mon, 29 Jun 2026 11:23:56 +0200 Subject: [PATCH] fix(rbac) : gate les listes Gitea/BookStack par projects.manage (et non ROLE_USER) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suite à la revue de sécurité : ROLE_ADMIN était trop strict (les ressources sœurs sont en ROLE_USER) mais ROLE_USER brut est trop permissif — ces endpoints listent TOUS les dépôts/étagères visibles par le token d'intégration global, sans filtrage par utilisateur. Comme ils ne sont consommés que par le ProjectDrawer (configuration du dépôt/étagère d'un projet), on les gate sur la permission métier project-management.projects.manage. Les admins conservent l'accès via le bypass ROLE_ADMIN du PermissionVoter. --- .../Infrastructure/ApiPlatform/Resource/BookStackShelf.php | 4 +++- .../Infrastructure/ApiPlatform/Resource/GiteaRepository.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Module/Integration/Infrastructure/ApiPlatform/Resource/BookStackShelf.php b/src/Module/Integration/Infrastructure/ApiPlatform/Resource/BookStackShelf.php index ec55760..13115db 100644 --- a/src/Module/Integration/Infrastructure/ApiPlatform/Resource/BookStackShelf.php +++ b/src/Module/Integration/Infrastructure/ApiPlatform/Resource/BookStackShelf.php @@ -15,7 +15,9 @@ use Symfony\Component\Serializer\Attribute\Groups; uriTemplate: '/bookstack/shelves', normalizationContext: ['groups' => ['bookstack_shelf:read']], provider: BookStackShelfProvider::class, - security: "is_granted('ROLE_USER')", + // Liste toutes les étagères visibles par le token BookStack global : + // réservé à qui configure un projet (ProjectDrawer), pas à tout user. + security: "is_granted('project-management.projects.manage')", ), ], )] diff --git a/src/Module/Integration/Infrastructure/ApiPlatform/Resource/GiteaRepository.php b/src/Module/Integration/Infrastructure/ApiPlatform/Resource/GiteaRepository.php index 6ed68d6..f298509 100644 --- a/src/Module/Integration/Infrastructure/ApiPlatform/Resource/GiteaRepository.php +++ b/src/Module/Integration/Infrastructure/ApiPlatform/Resource/GiteaRepository.php @@ -15,7 +15,9 @@ use Symfony\Component\Serializer\Attribute\Groups; uriTemplate: '/gitea/repositories', normalizationContext: ['groups' => ['gitea_repo:read']], provider: GiteaRepositoryProvider::class, - security: "is_granted('ROLE_USER')", + // Liste l'intégralité des dépôts visibles par le token Gitea global : + // réservé à qui configure un projet (ProjectDrawer), pas à tout user. + security: "is_granted('project-management.projects.manage')", ), ], )]