Skip to content

Commit 9358fc0

Browse files
committed
Add try/catch to finding of original SP
The original SP is not always returning an SP entity, but sometimes throws an Entity not found exception. This is probably warranted, but will be caught later in the process. This was breaking for the debug authentication. Where the internal sp entity id of EB is used as the issuer of the authn request. This yielded an entity not found exception from the repositories as internal entities are not stored in the database anymore. Simply catching the exception and continuing with the issuer sp entity id should solve this issue
1 parent 96e9d27 commit 9358fc0

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

library/EngineBlock/Corto/ProxyServer.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@
1616
* limitations under the License.
1717
*/
1818

19-
use OpenConext\EngineBlock\Metadata\Loa;
20-
use OpenConext\EngineBlock\Metadata\MfaEntity;
21-
use OpenConext\EngineBlock\Metadata\TransparentMfaEntity;
22-
use OpenConext\EngineBlockBundle\Authentication\AuthenticationState;
2319
use OpenConext\EngineBlock\Metadata\Entity\AbstractRole;
2420
use OpenConext\EngineBlock\Metadata\Entity\IdentityProvider;
2521
use OpenConext\EngineBlock\Metadata\Entity\ServiceProvider;
22+
use OpenConext\EngineBlock\Metadata\Loa;
23+
use OpenConext\EngineBlock\Metadata\MetadataRepository\EntityNotFoundException;
2624
use OpenConext\EngineBlock\Metadata\MetadataRepository\MetadataRepositoryInterface;
25+
use OpenConext\EngineBlock\Metadata\MfaEntity;
2726
use OpenConext\EngineBlock\Metadata\Service;
27+
use OpenConext\EngineBlock\Metadata\TransparentMfaEntity;
28+
use OpenConext\EngineBlockBundle\Authentication\AuthenticationState;
2829
use OpenConext\Value\Saml\Entity;
2930
use OpenConext\Value\Saml\EntityId;
3031
use OpenConext\Value\Saml\EntityType;
@@ -416,8 +417,15 @@ public function sendAuthenticationRequest(
416417
throw new EngineBlock_Corto_ProxyServer_Exception(sprintf('Unknown message type: "%s"', get_class($sspMessage)));
417418
}
418419

420+
try {
421+
$originalSpEnitytId = $this->findOriginalServiceProvider($spRequest, $this->_logger)->entityId;
422+
} catch (EntityNotFoundException $e) {
423+
// On debug requests, the entity ID can not be found in the database as this is the EngineBlock internal
424+
// entity which does not reside in the database.
425+
$originalSpEnitytId = $spEntityId;
426+
}
419427
// Add authncontextclassref if configured
420-
$service = $identityProvider->getCoins()->mfaEntities()->findByEntityId($this->findOriginalServiceProvider($spRequest, $this->_logger)->entityId);
428+
$service = $identityProvider->getCoins()->mfaEntities()->findByEntityId($originalSpEnitytId);
421429
if ($service instanceof MfaEntity) {
422430
$sspMessage->setRequestedAuthnContext([
423431
'AuthnContextClassRef' => [

0 commit comments

Comments
 (0)