This repository was archived by the owner on Sep 19, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed
Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments