From 64fca25a48c6ad3fb490b7039eeee3b6eb19153f Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Fri, 2 Jul 2021 15:57:27 +0200
Subject: [PATCH] Silently continue on missing identifyingAttribute

---
 modules/core/lib/Auth/Process/TargetedID.php | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/modules/core/lib/Auth/Process/TargetedID.php b/modules/core/lib/Auth/Process/TargetedID.php
index b4648d02d..dfdf5fbff 100644
--- a/modules/core/lib/Auth/Process/TargetedID.php
+++ b/modules/core/lib/Auth/Process/TargetedID.php
@@ -9,6 +9,7 @@ use SAML2\Constants;
 use SAML2\XML\saml\NameID;
 use SimpleSAML\Assert\Assert;
 use SimpleSAML\Auth;
+use SimpleSAML\Logger;
 use SimpleSAML\Utils;
 
 /**
@@ -100,14 +101,16 @@ class TargetedID extends Auth\ProcessingFilter
     public function process(array &$state): void
     {
         Assert::keyExists($state, 'Attributes');
-        Assert::keyExists(
-            $state['Attributes'],
-            $this->identifyingAttribute,
-            sprintf(
-                "core:TargetedID: Missing attribute '%s', which is needed to generate the targeted ID.",
-                $this->identifyingAttribute
-            )
-        );
+        if (!array_key_exists($this->identifyingAttribute, $state['Attributes'])) {
+            Logger::warning(
+                sprintf(
+                    "core:TargetedID: Missing attribute '%s', which is needed to generate the TargetedID.",
+                    $this->identifyingAttribute
+                )
+            );
+
+            return;
+        }
 
         $userID = $state['Attributes'][$this->identifyingAttribute][0];
         Assert::stringNotEmpty($userID);
-- 
GitLab