Skip to content

Commit 68b8c60

Browse files
committed
Implement state control
1 parent 6c7e221 commit 68b8c60

File tree

79 files changed

+839
-385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+839
-385
lines changed

app/config/parameters.yml.dist

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ parameters:
231231
feature_enable_consent: true
232232
feature_stepup_sfo_override_engine_entityid: false
233233
feature_enable_idp_initiated_flow: true
234-
feature_enable_sram_interrupt: false
234+
feature_enable_sram_interrupt: true
235235

236236
##########################################################################################
237237
## PROFILE SETTINGS
@@ -318,8 +318,14 @@ parameters:
318318
##########################################################################################
319319
## Config for connecting with SBS server
320320
## base_url must end with /. Locations must not start with /.
321-
sram.api_token: "xxx"
322-
sram.base_url: "http://127.0.0.1:12345/api/"
323-
sram.authz_location: "authz"
324-
sram.interrupt_location: "interrupt"
325-
sram.entitlements_location: "entitlements"
321+
sram.api_token: xxx
322+
sram.base_url: 'https://engine.dev.openconext.local/functional-testing/'
323+
sram.authz_location: authz
324+
sram.interrupt_location: interrupt
325+
sram.entitlements_location: entitlements
326+
sram.verify_peer: false
327+
sram.allowed_attributes:
328+
- eduPersonEntitlement
329+
- eduPersonPrincipalName
330+
- uid
331+
- sshkey

ci/qa/behat.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ echo -e "\nInstalling database fixtures...\n"
1616
./app/console doctrine:schema:drop --force --env=ci
1717
./app/console doctrine:schema:create --env=ci
1818

19-
#echo -e "\nPreparing frontend assets\n"
20-
#EB_THEME=skeune ./theme/scripts/prepare-test.js > /dev/null
19+
echo -e "\nPreparing frontend assets\n"
20+
EB_THEME=skeune ./theme/scripts/prepare-test.js > /dev/null
2121

2222
chown -R www-data app/cache/
2323
chmod -R 0777 /tmp/eb-fixtures

docs/filter_commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ Uses:
344344
- EngineBlock_Saml2_AuthnRequestAnnotationDecorator
345345

346346
### SRAM test filter
347-
<<Add description here>>
347+
When enabled and the SP has the collab_enabled coin, the SBS integration flow will be activated allowing SRAM integration.
348348

349349

350350

library/EngineBlock/Application/DiContainer.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use OpenConext\EngineBlock\Stepup\StepupEntityFactory;
2727
use OpenConext\EngineBlock\Stepup\StepupGatewayCallOutHelper;
2828
use OpenConext\EngineBlock\Validator\AllowedSchemeValidator;
29+
use OpenConext\EngineBlockBundle\Sbs\SbsAttributeMerger;
2930
use Symfony\Component\DependencyInjection\ContainerInterface as SymfonyContainerInterface;
3031

3132
class EngineBlock_Application_DiContainer extends Pimple
@@ -306,6 +307,11 @@ protected function getSymfonyContainer()
306307
return $this->container;
307308
}
308309

310+
public function getSbsAttributeMerger(): SbsAttributeMerger
311+
{
312+
return $this->container->get('engineblack.sbs.attribute_merger');
313+
}
314+
309315
public function getSbsClient(): \OpenConext\EngineBlockBundle\Sbs\SbsClientInterface
310316
{
311317
return $this->container->get('engineblock.sbs.sbs_client');

library/EngineBlock/Application/ErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function exception(Throwable $e)
6464
}
6565

6666
$this->_application->reportError($e);
67-
die($e->getMessage());
67+
6868
$message = 'An exceptional condition occurred. Contact support if this error persists.';
6969
die($message);
7070
}

library/EngineBlock/Application/FunctionalTestDiContainer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,4 @@ public function getEncryptionKeysConfiguration()
8181
],
8282
];
8383
}
84-
85-
8684
}

library/EngineBlock/Corto/Filter/Command/SRAMTestFilter.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use OpenConext\EngineBlockBundle\Configuration\FeatureConfigurationInterface;
44
use OpenConext\EngineBlockBundle\Exception\InvalidSbsResponseException;
55
use OpenConext\EngineBlockBundle\Sbs\Dto\AuthzRequest;
6+
use OpenConext\EngineBlockBundle\Sbs\SbsAttributeMerger;
67

78
/**
89
* Copyright 2021 Stichting Kennisnet
@@ -48,29 +49,17 @@ public function execute(): void
4849

4950
try {
5051
$request = $this->buildRequest();
52+
5153
$interruptResponse = $this->getSbsClient()->authz($request);
5254

5355
if ($interruptResponse->msg === 'interrupt') {
54-
// @TODO Consider if this should be an attribute?
5556
$this->_response->setSRAMInterruptNonce($interruptResponse->nonce);
5657
} elseif ($interruptResponse->msg === 'authorized' && !empty($interruptResponse->attributes)) {
57-
// @TODO make sure this has test coverage
58-
// @TODO Discussed with Bas/Peter: Add list of allowed parameter names via parameters.yml
59-
/**
60-
* "eduPersonEntitlement": ["[email protected]", "[email protected]"],
61-
* "eduPersonPrincipalName": ["[email protected]"],
62-
* "uid": ["test_user"],
63-
* "sshkey": ["ssh_key1", "ssh_key2"]
64-
*/
65-
$this->_responseAttributes = array_merge_recursive(
66-
$this->_responseAttributes,
67-
$interruptResponse->attributes
68-
);
58+
$this->_responseAttributes = $this->getSbsAttributeMerger()->mergeAttributes($this->_responseAttributes, $interruptResponse->attributes);
6959
} else {
7060
throw new InvalidSbsResponseException(sprintf('Invalid SBS response received: %s', $interruptResponse->msg));
7161
}
7262
}catch (Throwable $e){
73-
die($e->getMessage());
7463
throw new EngineBlock_Exception_SbsCheckFailed('The SBS server could not be queried: ' . $e->getMessage());
7564
}
7665
}
@@ -85,6 +74,11 @@ private function getFeatureConfiguration(): FeatureConfigurationInterface
8574
return EngineBlock_ApplicationSingleton::getInstance()->getDiContainer()->getFeatureConfiguration();
8675
}
8776

77+
private function getSbsAttributeMerger(): SbsAttributeMerger
78+
{
79+
return EngineBlock_ApplicationSingleton::getInstance()->getDiContainer()->getSbsAttributeMerger();
80+
}
81+
8882
/**
8983
* @return AuthzRequest
9084
* @throws EngineBlock_Corto_ProxyServer_Exception
@@ -94,7 +88,6 @@ private function buildRequest(): AuthzRequest
9488
$attributes = $this->getResponseAttributes();
9589
$id = $this->_request->getId();
9690

97-
// @TODO Check: can it occur this is not set?
9891
$user_id = $attributes['urn:mace:dir:attribute-def:uid'][0];
9992
$continue_url = $this->_server->getUrl('SRAMInterruptService', '') . "?ID=$id";
10093
$service_id = $this->_serviceProvider->entityId;

library/EngineBlock/Corto/Filter/Input.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,13 @@ public function getCommands()
9090
$diContainer->getAttributeAggregationClient()
9191
),
9292

93+
new EngineBlock_Corto_Filter_Command_SRAMTestFilter(),
94+
9395
// Check if the Policy Decision Point needs to be consulted for this request
9496
new EngineBlock_Corto_Filter_Command_EnforcePolicy(),
9597

9698
// Apply the Attribute Release Policy before we do consent.
9799
new EngineBlock_Corto_Filter_Command_AttributeReleasePolicy(),
98-
99-
/* @TODO According to spec, this should be between AttributeAggregator and EnforcePolicy.
100-
* Why is it here? */
101-
new EngineBlock_Corto_Filter_Command_SRAMTestFilter(),
102100
);
103101

104102
if (!$featureConfiguration->isEnabled('eb.run_all_manipulations_prior_to_consent')) {

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,14 @@ public function serve($serviceName, Request $httpRequest)
175175
$log->info('Handle SRAM Interrupt callout');
176176

177177
// Add the SRAM step
178-
$currentProcessStep = $this->_processingStateHelper->addStep(
178+
$this->_processingStateHelper->addStep(
179179
$receivedRequest->getId(),
180180
ProcessingStateHelperInterface::STEP_SRAM,
181181
$this->getEngineSpRole($this->_server),
182182
$receivedResponse
183183
);
184184

185-
// Redirect to SBS?
186-
// It sets the header?
185+
// Redirect to SRAM
187186
$this->_server->sendSRAMInterruptRequest($receivedResponse, $receivedRequest);
188187
}
189188

@@ -231,7 +230,6 @@ public function serve($serviceName, Request $httpRequest)
231230
$nameId,
232231
$sp->getCoins()->isStepupForceAuthn()
233232
);
234-
235233
}
236234

237235
/**

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use OpenConext\EngineBlock\Service\ProcessingStateHelperInterface;
2121
use OpenConext\EngineBlock\Stepup\StepupGatewayCallOutHelper;
2222
use OpenConext\EngineBlockBundle\Sbs\Dto\EntitlementsRequest;
23+
use OpenConext\EngineBlockBundle\Sbs\SbsAttributeMerger;
2324
use Symfony\Component\HttpFoundation\Request;
2425

2526
class EngineBlock_Corto_Module_Service_SRAMInterrupt
@@ -45,18 +46,25 @@ class EngineBlock_Corto_Module_Service_SRAMInterrupt
4546
*/
4647
private $_stepupGatewayCallOutHelper;
4748

49+
/**
50+
* @var SbsAttributeMerger
51+
*/
52+
private $sbsAttributeMerger;
53+
4854

4955
public function __construct(
5056
EngineBlock_Corto_ProxyServer $server,
5157
AuthenticationStateHelperInterface $stateHelper,
5258
ProcessingStateHelperInterface $processingStateHelper,
53-
StepupGatewayCallOutHelper $stepupGatewayCallOutHelper
59+
StepupGatewayCallOutHelper $stepupGatewayCallOutHelper,
60+
SbsAttributeMerger $sbsAttributeMerger
5461
)
5562
{
5663
$this->_server = $server;
5764
$this->_authenticationStateHelper = $stateHelper;
5865
$this->_processingStateHelper = $processingStateHelper;
5966
$this->_stepupGatewayCallOutHelper = $stepupGatewayCallOutHelper;
67+
$this->sbsAttributeMerger = $sbsAttributeMerger;
6068
}
6169

6270
/**
@@ -69,7 +77,6 @@ public function __construct(
6977
*/
7078
public function serve($serviceName, Request $httpRequest)
7179
{
72-
/** @TODO How to test this class? */
7380
$application = EngineBlock_ApplicationSingleton::getInstance();
7481

7582
// Get active request
@@ -90,18 +97,10 @@ public function serve($serviceName, Request $httpRequest)
9097
$interruptResponse = $this->getSbsClient()->requestEntitlementsFor($request);
9198

9299
if (!empty($interruptResponse->attributes)) {
93-
/**
94-
* @TODO make sure this has test coverage
95-
*/
96-
$attributes = array_merge_recursive($attributes, $interruptResponse->attributes);
100+
$attributes = $this->sbsAttributeMerger->mergeAttributes($attributes, $interruptResponse->attributes);
97101
$receivedResponse->getAssertion()->setAttributes($attributes);
98102
}
99103

100-
/**
101-
* @JOHAN Waarom zit hier stepup in? Zou dat niet via de 'reguliere' flow afgetrapt moeten worden?
102-
* Kunnen we hier \EngineBlock_Corto_Module_Service_AssertionConsumer::serve gebruiken? Code daar wegsplitsen naar een shared service?
103-
*/
104-
105104
/*
106105
* Continue to Consent/StepUp
107106
*/
@@ -135,7 +134,7 @@ public function serve($serviceName, Request $httpRequest)
135134
return;
136135
}
137136

138-
$log->info('Handle Stepup authentication callout');
137+
$this->_server->getLogger()->info('Handle Stepup authentication callout');
139138

140139
// Add Stepup authentication step
141140
$currentProcessStep = $this->_processingStateHelper->addStep(

0 commit comments

Comments
 (0)