diff --git a/lib/Disco.php b/lib/Disco.php
index 1c4af10517437fda969be9e618d05d6b2748f12f..1063e0f66c7d15dc4561b3517bacc810ec164508 100644
--- a/lib/Disco.php
+++ b/lib/Disco.php
@@ -292,6 +292,11 @@ class Disco extends PowerIdPDisco
             }
         }
 
+        if (!empty($this->originalsp[Disco::METADATA_ONLY_ALLOWED_IDPS])) {
+            $onlyAllowedIdps = $this->originalsp[Disco::METADATA_ONLY_ALLOWED_IDPS];
+            $onlyAllowedIdps = array_fill_keys($onlyAllowedIdps, 1);
+        }
+
         if ($this->processAarcIdpHintEnabled) {
             $hintedIdp = $this->processAarcIdpHint($this->state, $hintedIdp);
         }
@@ -310,7 +315,11 @@ class Disco extends PowerIdPDisco
             // either will throw an exception or redirect user, we can end prematurely
             return;
         } elseif (sizeof($idpList) === 1) {
-            Logger::info(self::DEBUG_PREFIX . 'Only one Idp left. Redirecting automatically. IdP: ' . $idpList[0]);
+            Logger::info(
+                self::DEBUG_PREFIX .
+                'Only one Idp left. Redirecting automatically. IdP: ' .
+                array_key_first($idpList)
+            );
             $idp = array_keys($idpList)[0];
             self::redirectToIdP($idp);
         }