Skip to content

Commit b47f786

Browse files
committed
Add the new role
The new API roles are bundled with another role for readability, no intent at this point to make this something which we can assign to users.
1 parent e8c1e4b commit b47f786

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

webapp/config/packages/security.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
security:
44
role_hierarchy:
55
ROLE_JURY: [ROLE_CLARIFICATION_RW, ROLE_API, ROLE_API_READER, ROLE_API_SOURCE_READER]
6-
ROLE_ADMIN: [ROLE_JURY, ROLE_JUDGEHOST, ROLE_API_WRITER, ROLE_API_PROBLEM_CHANGE]
6+
ROLE_API_ADMIN: [ROLE_API_PROBLEM_CHANGE, ROLE_API_CONTEST_CHANGE]
7+
ROLE_ADMIN: [ROLE_JURY, ROLE_JUDGEHOST, ROLE_API_WRITER, ROLE_API_ADMIN]
78
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
89

9-
1010
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
1111
password_hashers:
1212
App\Entity\User:

webapp/src/Controller/API/ContestController.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function __construct(
7474
* Add a new contest.
7575
* @throws BadRequestHttpException
7676
*/
77-
#[IsGranted('ROLE_ADMIN')]
77+
#[IsGranted('ROLE_API_CONTEST_CHANGE')]
7878
#[Rest\Post('')]
7979
#[OA\RequestBody(
8080
required: true,
@@ -200,7 +200,7 @@ public function bannerAction(Request $request, string $cid): Response
200200
/**
201201
* Delete the banner for the given contest.
202202
*/
203-
#[IsGranted('ROLE_ADMIN')]
203+
#[IsGranted('ROLE_API_CONTEST_CHANGE')]
204204
#[Rest\Delete('/{cid}/banner', name: 'delete_contest_banner')]
205205
#[OA\Response(response: 204, description: 'Deleting banner succeeded')]
206206
#[OA\Parameter(ref: '#/components/parameters/cid')]
@@ -220,7 +220,7 @@ public function deleteBannerAction(Request $request, string $cid): Response
220220
/**
221221
* Set the banner for the given contest.
222222
*/
223-
#[IsGranted('ROLE_ADMIN')]
223+
#[IsGranted('ROLE_API_CONTEST_CHANGE')]
224224
#[Rest\Post("/{cid}/banner", name: 'post_contest_banner')]
225225
#[Rest\Put("/{cid}/banner", name: 'put_contest_banner')]
226226
#[OA\RequestBody(
@@ -268,7 +268,7 @@ public function setBannerAction(Request $request, string $cid, ValidatorInterfac
268268
/**
269269
* Delete the problemset document for the given contest.
270270
*/
271-
#[IsGranted('ROLE_ADMIN')]
271+
#[IsGranted('ROLE_API_CONTEST_CHANGE')]
272272
#[Rest\Delete('/{cid}/problemset', name: 'delete_contest_problemset')]
273273
#[OA\Response(response: 204, description: 'Deleting problemset document succeeded')]
274274
#[OA\Parameter(ref: '#/components/parameters/cid')]
@@ -288,7 +288,7 @@ public function deleteProblemsetAction(Request $request, string $cid): Response
288288
/**
289289
* Set the problemset document for the given contest.
290290
*/
291-
#[IsGranted('ROLE_ADMIN')]
291+
#[IsGranted('ROLE_API_CONTEST_CHANGE')]
292292
#[Rest\Post("/{cid}/problemset", name: 'post_contest_problemset')]
293293
#[Rest\Put("/{cid}/problemset", name: 'put_contest_problemset')]
294294
#[OA\RequestBody(

webapp/src/DataFixtures/DefaultData/RoleFixture.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public function load(ObjectManager $manager): void
2929
'api_writer' => 'API writer',
3030
'api_source_reader' => 'Source code reader',
3131
'clarification_rw' => 'Clarification handler',
32-
'api_problem_change' => 'API Problem Changer'
32+
'api_problem_change' => 'API Problem Changer',
33+
'api_contest_change' => 'API Contest Changer'
3334
];
3435
foreach ($roles as $roleName => $description) {
3536
if (!($role = $manager->getRepository(Role::class)->findOneBy(['dj_role' => $roleName]))) {

0 commit comments

Comments
 (0)