refactor(core) : RBAC #345 - replace ROLE_ADMIN placeholders with RBAC codes
This commit is contained in:
@@ -19,13 +19,11 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
|||||||
operations: [
|
operations: [
|
||||||
new GetCollection(
|
new GetCollection(
|
||||||
normalizationContext: ['groups' => ['permission:read']],
|
normalizationContext: ['groups' => ['permission:read']],
|
||||||
// TODO ticket #345 : remplacer par is_granted('core.permissions.view')
|
security: "is_granted('core.permissions.view')",
|
||||||
security: "is_granted('ROLE_ADMIN')",
|
|
||||||
),
|
),
|
||||||
new Get(
|
new Get(
|
||||||
normalizationContext: ['groups' => ['permission:read']],
|
normalizationContext: ['groups' => ['permission:read']],
|
||||||
// TODO ticket #345 : remplacer par is_granted('core.permissions.view')
|
security: "is_granted('core.permissions.view')",
|
||||||
security: "is_granted('ROLE_ADMIN')",
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)]
|
)]
|
||||||
|
|||||||
@@ -35,31 +35,26 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
operations: [
|
operations: [
|
||||||
new GetCollection(
|
new GetCollection(
|
||||||
normalizationContext: ['groups' => ['role:read']],
|
normalizationContext: ['groups' => ['role:read']],
|
||||||
// TODO ticket #345 : remplacer par is_granted('core.roles.manage')
|
security: "is_granted('core.roles.view')",
|
||||||
security: "is_granted('ROLE_ADMIN')",
|
|
||||||
),
|
),
|
||||||
new Get(
|
new Get(
|
||||||
normalizationContext: ['groups' => ['role:read']],
|
normalizationContext: ['groups' => ['role:read']],
|
||||||
// TODO ticket #345 : remplacer par is_granted('core.roles.manage')
|
security: "is_granted('core.roles.view')",
|
||||||
security: "is_granted('ROLE_ADMIN')",
|
|
||||||
),
|
),
|
||||||
new Post(
|
new Post(
|
||||||
normalizationContext: ['groups' => ['role:read']],
|
normalizationContext: ['groups' => ['role:read']],
|
||||||
denormalizationContext: ['groups' => ['role:write']],
|
denormalizationContext: ['groups' => ['role:write']],
|
||||||
// TODO ticket #345 : remplacer par is_granted('core.roles.manage')
|
security: "is_granted('core.roles.manage')",
|
||||||
security: "is_granted('ROLE_ADMIN')",
|
|
||||||
processor: RoleProcessor::class,
|
processor: RoleProcessor::class,
|
||||||
),
|
),
|
||||||
new Patch(
|
new Patch(
|
||||||
normalizationContext: ['groups' => ['role:read']],
|
normalizationContext: ['groups' => ['role:read']],
|
||||||
denormalizationContext: ['groups' => ['role:write']],
|
denormalizationContext: ['groups' => ['role:write']],
|
||||||
// TODO ticket #345 : remplacer par is_granted('core.roles.manage')
|
security: "is_granted('core.roles.manage')",
|
||||||
security: "is_granted('ROLE_ADMIN')",
|
|
||||||
processor: RoleProcessor::class,
|
processor: RoleProcessor::class,
|
||||||
),
|
),
|
||||||
new Delete(
|
new Delete(
|
||||||
// TODO ticket #345 : remplacer par is_granted('core.roles.manage')
|
security: "is_granted('core.roles.manage')",
|
||||||
security: "is_granted('ROLE_ADMIN')",
|
|
||||||
processor: RoleProcessor::class,
|
processor: RoleProcessor::class,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use ApiPlatform\Metadata\GetCollection;
|
|||||||
use ApiPlatform\Metadata\Patch;
|
use ApiPlatform\Metadata\Patch;
|
||||||
use ApiPlatform\Metadata\Post;
|
use ApiPlatform\Metadata\Post;
|
||||||
use App\Module\Core\Infrastructure\ApiPlatform\State\Processor\UserPasswordHasherProcessor;
|
use App\Module\Core\Infrastructure\ApiPlatform\State\Processor\UserPasswordHasherProcessor;
|
||||||
|
use App\Module\Core\Infrastructure\ApiPlatform\State\Processor\UserProcessor;
|
||||||
use App\Module\Core\Infrastructure\ApiPlatform\State\Processor\UserRbacProcessor;
|
use App\Module\Core\Infrastructure\ApiPlatform\State\Processor\UserRbacProcessor;
|
||||||
use App\Module\Core\Infrastructure\ApiPlatform\State\Provider\MeProvider;
|
use App\Module\Core\Infrastructure\ApiPlatform\State\Provider\MeProvider;
|
||||||
use App\Module\Core\Infrastructure\Doctrine\DoctrineUserRepository;
|
use App\Module\Core\Infrastructure\Doctrine\DoctrineUserRepository;
|
||||||
@@ -31,25 +32,24 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
|
|||||||
normalizationContext: ['groups' => ['me:read']],
|
normalizationContext: ['groups' => ['me:read']],
|
||||||
),
|
),
|
||||||
new Get(
|
new Get(
|
||||||
security: "is_granted('ROLE_ADMIN')", // TODO ticket #345 : remplacer par is_granted('core.users.view')
|
security: "is_granted('core.users.view')",
|
||||||
normalizationContext: ['groups' => ['user:list']],
|
normalizationContext: ['groups' => ['user:list']],
|
||||||
),
|
),
|
||||||
new GetCollection(
|
new GetCollection(
|
||||||
security: "is_granted('ROLE_ADMIN')", // TODO ticket #345 : remplacer par is_granted('core.users.view')
|
security: "is_granted('core.users.view')",
|
||||||
normalizationContext: ['groups' => ['user:list']],
|
normalizationContext: ['groups' => ['user:list']],
|
||||||
),
|
),
|
||||||
new Post(security: "is_granted('ROLE_ADMIN')", processor: UserPasswordHasherProcessor::class),
|
new Post(security: "is_granted('core.users.manage')", processor: UserPasswordHasherProcessor::class),
|
||||||
new Patch(security: "is_granted('ROLE_ADMIN')", processor: UserPasswordHasherProcessor::class),
|
new Patch(security: "is_granted('core.users.manage')", processor: UserPasswordHasherProcessor::class),
|
||||||
new Patch(
|
new Patch(
|
||||||
name: 'user_rbac_patch',
|
name: 'user_rbac_patch',
|
||||||
uriTemplate: '/users/{id}/rbac',
|
uriTemplate: '/users/{id}/rbac',
|
||||||
// TODO ticket #345 : remplacer par is_granted('core.users.manage')
|
security: "is_granted('core.users.manage')",
|
||||||
security: "is_granted('ROLE_ADMIN')",
|
|
||||||
normalizationContext: ['groups' => ['user:rbac:read']],
|
normalizationContext: ['groups' => ['user:rbac:read']],
|
||||||
denormalizationContext: ['groups' => ['user:rbac:write']],
|
denormalizationContext: ['groups' => ['user:rbac:write']],
|
||||||
processor: UserRbacProcessor::class,
|
processor: UserRbacProcessor::class,
|
||||||
),
|
),
|
||||||
new Delete(security: "is_granted('ROLE_ADMIN')"),
|
new Delete(security: "is_granted('core.users.manage')", processor: UserProcessor::class),
|
||||||
],
|
],
|
||||||
denormalizationContext: ['groups' => ['user:write']],
|
denormalizationContext: ['groups' => ['user:write']],
|
||||||
)]
|
)]
|
||||||
|
|||||||
Reference in New Issue
Block a user