Skip to content

Commit e92841d

Browse files
committed
Call Di-Container once
1 parent 1cf554c commit e92841d

3 files changed

Lines changed: 10 additions & 37 deletions

File tree

library/EngineBlock/Corto/Module/Service/SingleSignOn.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ public function serve($serviceName, Request $httpRequest)
194194
}
195195

196196
// Multiple IdPs found...
197-
197+
$container = $application->getDiContainer();
198198
// Auto-select IdP when 'feature_enable_sso_notification' is enabled and send AuthenticationRequest on success
199-
if ($application->getDiContainer()->getFeatureConfiguration()->isEnabled("eb.enable_sso_notification")) {
200-
$idpEntityId = $application->getDiContainer()->getSsoNotificationService()->
201-
handleSsoNotification($application->getDiContainer()->getSymfonyRequest()->cookies, $this->_server);
199+
if ($container->getFeatureConfiguration()->isEnabled("eb.enable_sso_notification")) {
200+
$idpEntityId = $container->getSsoNotificationService()
201+
->handleSsoNotification($container->getSymfonyRequest()->cookies, $this->_server);
202202

203203
if (!empty($idpEntityId)) {
204204
try {
@@ -214,8 +214,8 @@ public function serve($serviceName, Request $httpRequest)
214214
}
215215

216216
// Auto-select IdP when 'wayf.rememberChoice' feature is enabled and is allowed for the current request
217-
if (($application->getDiContainer()->getRememberChoice() === true) && !($request->getForceAuthn() || $request->isDebugRequest())) {
218-
$cookies = $application->getDiContainer()->getSymfonyRequest()->cookies->all();
217+
if (($container->getRememberChoice() === true) && !($request->getForceAuthn() || $request->isDebugRequest())) {
218+
$cookies = $container->getSymfonyRequest()->cookies->all();
219219
if (array_key_exists('rememberchoice', $cookies)) {
220220
$remembered = json_decode($cookies['rememberchoice']);
221221
if (array_search($remembered, $candidateIDPs) !== false) {
@@ -234,10 +234,10 @@ public function serve($serviceName, Request $httpRequest)
234234
return;
235235
}
236236

237-
$authnRequestRepository = $application->getDiContainer()->getAuthnRequestSessionRepository();
237+
$authnRequestRepository = $container->getAuthnRequestSessionRepository();
238238
$authnRequestRepository->store($request);
239239

240-
$correlationIdRepository = $application->getDiContainer()->getCorrelationIdRepository();
240+
$correlationIdRepository = $container->getCorrelationIdRepository();
241241
$correlationIdRepository->mint($request->getId());
242242
$correlationIdRepository->resolve($request->getId());
243243

library/EngineBlock/Corto/ProxyServer.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,7 @@ public function sendAuthenticationRequest(
470470
$authnRequestRepository->store($spRequest);
471471
$authnRequestRepository->link($ebRequest, $spRequest);
472472

473-
$correlationIdRepository = EngineBlock_ApplicationSingleton::getInstance()
474-
->getDiContainer()
475-
->getCorrelationIdRepository();
473+
$correlationIdRepository = $diContainer->getCorrelationIdRepository();
476474
$correlationIdRepository->mint($spRequest->getId());
477475
$correlationIdRepository->link($ebRequest->getId(), $spRequest->getId());
478476
$correlationIdRepository->resolve($spRequest->getId());
@@ -561,9 +559,7 @@ public function sendStepupAuthenticationRequest(
561559
$authnRequestRepository->store($spRequest);
562560
$authnRequestRepository->link($ebRequest, $spRequest);
563561

564-
$correlationIdRepository = EngineBlock_ApplicationSingleton::getInstance()
565-
->getDiContainer()
566-
->getCorrelationIdRepository();
562+
$correlationIdRepository = $container->getCorrelationIdRepository();
567563
$correlationIdRepository->mint($spRequest->getId());
568564
$correlationIdRepository->link($ebRequest->getId(), $spRequest->getId());
569565
$correlationIdRepository->resolve($spRequest->getId());

tests/bootstrap.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,6 @@
2222

2323
require_once realpath(__DIR__) . '/../vendor/autoload.php';
2424

25-
$worktreeRoot = (string) realpath(__DIR__ . '/..');
26-
$vendorRealPath = (string) realpath(__DIR__ . '/../vendor');
27-
if (!str_starts_with($vendorRealPath, $worktreeRoot . DIRECTORY_SEPARATOR)) {
28-
$worktreeLibrary = $worktreeRoot . '/library';
29-
$worktreeSrc = $worktreeRoot . '/src';
30-
spl_autoload_register(static function (string $class) use ($worktreeLibrary, $worktreeSrc): bool {
31-
$psr0File = $worktreeLibrary . '/' . str_replace('_', '/', $class) . '.php';
32-
if (file_exists($psr0File)) {
33-
require $psr0File;
34-
return true;
35-
}
36-
if (str_starts_with($class, 'OpenConext\\')) {
37-
$relative = substr($class, strlen('OpenConext\\'));
38-
$psr4File = $worktreeSrc . '/OpenConext/' . str_replace('\\', '/', $relative) . '.php';
39-
if (file_exists($psr4File)) {
40-
require $psr4File;
41-
return true;
42-
}
43-
}
44-
return false;
45-
}, true, true);
46-
}
47-
4825
require_once realpath(__DIR__) . '/../src/Kernel.php';
4926

5027
$kernel = new Kernel('test', true);

0 commit comments

Comments
 (0)