Files
Lesstime/src/ApiResource/GiteaBranch.php
Matthieu e0dfcbdbf8 fix(security) : add role checks on Gitea API resources and all MCP tools
- GiteaBranch, GiteaBranchName, GiteaPullRequest: require ROLE_USER
- All 22 MCP tools: require ROLE_USER (ROLE_ADMIN for users/clients listing)

Tickets: T-002, T-007

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 15:27:16 +01:00

49 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\ApiResource;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use App\State\GiteaBranchProcessor;
use App\State\GiteaBranchProvider;
use Symfony\Component\Serializer\Attribute\Groups;
#[ApiResource(
operations: [
new GetCollection(
uriTemplate: '/tasks/{taskId}/gitea/branches',
normalizationContext: ['groups' => ['gitea_branch:read']],
provider: GiteaBranchProvider::class,
security: "is_granted('ROLE_USER')",
),
new Post(
uriTemplate: '/tasks/{taskId}/gitea/branches',
denormalizationContext: ['groups' => ['gitea_branch:write']],
normalizationContext: ['groups' => ['gitea_branch:read']],
provider: GiteaBranchProvider::class,
processor: GiteaBranchProcessor::class,
security: "is_granted('ROLE_USER')",
),
],
)]
final class GiteaBranch
{
#[Groups(['gitea_branch:read'])]
public string $name = '';
#[Groups(['gitea_branch:write'])]
public string $type = 'feature';
#[Groups(['gitea_branch:write'])]
public string $baseBranch = 'main';
/**
* @var array<array{sha: string, message: string, author: string, date: string}>
*/
#[Groups(['gitea_branch:read'])]
public array $commits = [];
}