Skip to content

Commit a72901c

Browse files
committed
Adjusting ACLs -- allow external group manager to create sub-groups.
1 parent 2b4e17c commit a72901c

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

app/V1Module/presenters/GroupExternalAttributesPresenter.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ public function actionDefault(string $instance, ?string $service, ?string $user)
9494
}
9595

9696

97-
public function checkAdd()
97+
public function checkAdd(string $groupId)
9898
{
99-
if (!$this->groupAcl->canSetExternalAttributes()) {
99+
$group = $this->groups->findOrThrow($groupId);
100+
if (!$this->groupAcl->canSetExternalAttributes($group)) {
100101
throw new ForbiddenRequestException();
101102
}
102103
}
@@ -128,9 +129,10 @@ public function actionAdd(string $groupId)
128129
$this->sendSuccessResponse("OK");
129130
}
130131

131-
public function checkRemove()
132+
public function checkRemove(string $groupId)
132133
{
133-
if (!$this->groupAcl->canSetExternalAttributes()) {
134+
$group = $this->groups->findOrThrow($groupId);
135+
if (!$this->groupAcl->canSetExternalAttributes($group)) {
134136
throw new ForbiddenRequestException();
135137
}
136138
}

app/V1Module/security/ACL/IGroupPermissions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ public function canUnlockStudent(Group $group, User $student): bool;
7878

7979
public function canViewExternalAttributes(): bool;
8080

81-
public function canSetExternalAttributes(): bool;
81+
public function canSetExternalAttributes(Group $group): bool;
8282
}

app/config/permissions.neon

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,28 @@ permissions:
7979
resource: group
8080
actions:
8181
- viewExternalAttributes
82+
83+
- allow: true
84+
role: scope-group-external
85+
resource: group
86+
actions:
8287
- setExternalAttributes
8388
- addStudent
8489
- removeStudent
8590
- addMember
8691
- removeMember
92+
- addSubgroup
93+
conditions:
94+
- group.isNotArchived
95+
96+
- allow: true
97+
resource: group
98+
role: scope-group-external
99+
actions:
100+
- addSubgroup
101+
conditions:
102+
- group.isNotArchived
103+
- group.isNotExam
87104

88105
- allow: true
89106
role: student

0 commit comments

Comments
 (0)