Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 65e2c1c

Browse files
committed
Added filtering for addInstitution app
* Now we filter out all whitelisted entityIds from list od all entityIds and users will not see whitelisted entityIds in addInstitution app.
1 parent 9e12729 commit 65e2c1c

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

lib/Disco.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ public function handleRequest()
6868

6969
// no choice possible. Show discovery service page
7070
$idpList = $this->getIdPList();
71-
$idpList = $this->filterList($idpList);
71+
if (isset($this->originalsp['disco.addInstitutionApp']) && $this->originalsp['disco.addInstitutionApp'] === true ) {
72+
$idpList = $this->filterAddInstitutionList($idpList);
73+
} else {
74+
$idpList = $this->filterList($idpList);
75+
}
7276
$preferredIdP = $this->getRecommendedIdP();
7377
$preferredIdP = array_key_exists($preferredIdP, $idpList) ? $preferredIdP : null;
7478

@@ -121,6 +125,29 @@ protected function filterList($list)
121125
return $list;
122126
}
123127

128+
/**
129+
* Filter a list of entities for addInstitution app according to if entityID is whitelisted or not
130+
*
131+
* @param array $list A map of entities to filter.
132+
* @return array The list in $list after filtering entities.
133+
* @throws SimpleSAML_Error_Exception if all IdPs are filtered out and no one left.
134+
*/
135+
protected function filterAddInstitutionList($list)
136+
{
137+
foreach ($list as $entityId => $idp) {
138+
if (in_array($entityId, $this->whitelist)){
139+
unset($list[$entityId]);
140+
}
141+
}
142+
143+
if (empty($list)) {
144+
throw new SimpleSAML_Error_Exception('All IdPs has been filtered out. And no one left.');
145+
}
146+
147+
return $list;
148+
149+
}
150+
124151
/**
125152
* Filter out IdP which are not in SAML2 Scoping attribute list (SAML2 feature)
126153
* @param $list

0 commit comments

Comments
 (0)