Skip to content

Commit bc8d34f

Browse files
authored
Update workgroup api response structure (#37)
1 parent a958bd4 commit bc8d34f

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

config/install/stanford_samlauth.settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ role_mapping:
1212
cert: ''
1313
key: ''
1414
timeout: 30
15+
include_admins: false
1516
mapping: {}

config/schema/stanford_samlauth.schema.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ stanford_samlauth.settings:
6767
timeout:
6868
type: integer
6969
label: API Request timeout limit
70+
include_admins:
71+
type: boolean
72+
label: Include administrators for role mapping
7073
reevaluate:
7174
type: string
7275
label: Reevaluation rule

src/Service/WorkgroupApi.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,19 @@ protected function callApi(string $workgroup = NULL, string $sunet = NULL): ?arr
202202
public function getAllUserWorkgroups(string $authname): array {
203203
$workgroup_names = [];
204204
if ($user_data = $this->callApi(NULL, $authname)) {
205-
foreach ($user_data['results'] as $user_member) {
205+
foreach ($user_data['members'] as $user_member) {
206206
$workgroup_names[] = $user_member['name'];
207207
}
208+
$includeAdmins = $this->configFactory->get('stanford_samlauth.settings')
209+
->get('role_mapping.workgroup_api.include_admins');
210+
211+
if ($includeAdmins) {
212+
foreach ($user_data['administrators'] as $user_member) {
213+
$workgroup_names[] = $user_member['name'];
214+
}
215+
}
208216
}
217+
209218
return $workgroup_names;
210219
}
211220

tests/src/Unit/Service/WorkgroupApiTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ public function guzzleRequestCallback($method, $url, $options) {
8686
switch ($options['query']['id']) {
8787
case 'uit:sws':
8888
$body = [
89-
'results' => [],
89+
'members' => [],
9090
];
9191
break;
9292

9393
case $this->authname:
9494
$body = [
95-
'results' => [['name' => 'valid:workgroup']],
95+
'members' => [['name' => 'valid:workgroup']],
9696
];
9797
break;
9898

0 commit comments

Comments
 (0)