-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support overriding StepUp EntityId #1279
Changes from 4 commits
f7e664d
eabfc29
57fe036
11578ad
457260c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,12 +73,15 @@ public function __construct( | |
*/ | ||
public function serve($serviceName, Request $httpRequest) | ||
{ | ||
$serviceEntityId = $this->_server->getUrl('stepupMetadataService'); | ||
$expectedDestination = $this->_server->getUrl('stepupAssertionConsumerService'); | ||
|
||
$application = EngineBlock_ApplicationSingleton::getInstance(); | ||
$log = $application->getLogInstance(); | ||
|
||
// EngineBlock will verify the incoming assertion's Audience which will | ||
// be set to the entityID it used on the outgoing AuthNRequest, so this | ||
// place will also need to handle the override if present. | ||
$serviceEntityId = $this->determineRemoteSpEntityId(); | ||
$expectedDestination = $this->_server->getUrl('stepupAssertionConsumerService'); | ||
|
||
$checkResponseSignature = true; | ||
try { | ||
$receivedResponse = $this->_server->getBindingsModule()->receiveResponse($serviceEntityId, $expectedDestination); | ||
|
@@ -138,6 +141,30 @@ public function serve($serviceName, Request $httpRequest) | |
return; | ||
} | ||
|
||
/** | ||
* Returns the `stepupMetadataService` if no override is defined. | ||
* To define an override (for StepUp key rollover) configure: | ||
* `eb.stepup.sfo.override_engine_entityid`. See UPGRADING.md (6.13 -> 6.14) | ||
* for details. | ||
* | ||
* @return string | ||
*/ | ||
private function determineRemoteSpEntityId() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WIll always return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure we can dash with return type definitions here? I could of course do a @var annotation. |
||
{ | ||
$application = EngineBlock_ApplicationSingleton::getInstance(); | ||
$container = $application->getDiContainer(); | ||
$entityIdOverrideValue = $container->getStepupEntityIdOverrideValue(); | ||
$features = $container->getFeatureConfiguration(); | ||
$isConfigured = $features->hasFeature('eb.stepup.sfo.override_engine_entityid'); | ||
$isEnabled = $features->isEnabled('eb.stepup.sfo.override_engine_entityid'); | ||
|
||
$serviceEntityId = $this->_server->getUrl('stepupMetadataService'); | ||
if ($isEnabled && $isConfigured) { | ||
return $entityIdOverrideValue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting the override causes this error down the line when EB is processing the assertion (stepupAssertionConsumerService)
|
||
} | ||
return $serviceEntityId; | ||
} | ||
|
||
/** | ||
* @return AuthenticationState | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
use OpenConext\EngineBlock\Exception\MissingParameterException; | ||
use OpenConext\EngineBlock\Metadata\Entity\AbstractRole; | ||
use OpenConext\EngineBlock\Metadata\Entity\IdentityProvider; | ||
use OpenConext\EngineBlock\Metadata\Entity\ServiceProvider; | ||
|
@@ -487,6 +488,32 @@ public function sendStepupAuthenticationRequest( | |
$nameIdOverwrite->setFormat(Constants::NAMEID_UNSPECIFIED); | ||
$sspMessage->setNameId($nameIdOverwrite); | ||
|
||
// See: UPGRADING.md -> ## 6.13 -> 6.14 | ||
$container = EngineBlock_ApplicationSingleton::getInstance()->getDiContainer(); | ||
$entityIdOverrideValue = $container->getStepupEntityIdOverrideValue(); | ||
$features = $container->getFeatureConfiguration(); | ||
$isConfigured = $features->hasFeature('eb.stepup.sfo.override_engine_entityid'); | ||
$isEnabled = $features->isEnabled('eb.stepup.sfo.override_engine_entityid'); | ||
|
||
if ($isEnabled && $isConfigured) { | ||
if (empty($entityIdOverrideValue)) { | ||
throw new MissingParameterException( | ||
'When feature "feature_stepup_sfo_override_engine_entityid" is enabled, | ||
you must provide the "stepup.sfo.override_engine_entityid" parameter.' | ||
); | ||
} | ||
$this->_logger->notice( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I prefer |
||
sprintf( | ||
'Feature eb.stepup.sfo.override_engine_entityid is enabled, overriding the Issuer of the AR to the ' . | ||
'StepUp Gateway. Updated the Issuer to "%s"', | ||
$entityIdOverrideValue | ||
) | ||
); | ||
$issuer = new Issuer(); | ||
$issuer->setValue($entityIdOverrideValue); | ||
$sspMessage->setIssuer($issuer); | ||
} | ||
|
||
// Link with the original Request | ||
$authnRequestRepository = new EngineBlock_Saml2_AuthnRequestSessionRepository($this->_logger); | ||
$authnRequestRepository->store($spRequest); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Feature: | ||
In order to facilitate a rolling configuration update | ||
As EngineBlock | ||
I want the SP entityID that is used for Stepup auth to be configurable so that at the same time | ||
that the EngineBlock default key is updated, this entityID can be changed. | ||
This then allows two entities, with two different keys, to be configured in the Stepup-Gateway | ||
|
||
Background: | ||
Given an EngineBlock instance on "vm.openconext.org" | ||
And no registered SPs | ||
And no registered Idps | ||
And an Identity Provider named "SSO-IdP" | ||
And a Service Provider named "SSO-SP" | ||
And an Identity Provider named "Dummy-IdP" | ||
And a Service Provider named "Dummy-SP" | ||
And a Service Provider named "Proxy-SP" | ||
|
||
Scenario: When stepup.sfo.override_engine_entityid is not configured, stepup/metadata should show default EntityId | ||
Given feature "eb.stepup.sfo.override_engine_entityid" is disabled | ||
When I go to Engineblock URL "/authentication/stepup/metadata" | ||
Then the response should match xpath '//md:EntityDescriptor[@entityID="https://engine.vm.openconext.org/authentication/stepup/metadata"]' | ||
|
||
Scenario: When stepup.sfo.override_engine_entityid is configured with a valid EntityId, stepup/metadata should show that EntityId | ||
Given feature "eb.stepup.sfo.override_engine_entityid" is enabled | ||
When I go to Engineblock URL "/authentication/stepup/metadata" | ||
Then the response should match xpath '//md:EntityDescriptor[@entityID="https://engine.vm.openconext.com/new/stepup/metadata"]' | ||
|
||
# Note that we can not ascertain programatically if the Issuer is updated as this is an internal | ||
# redirect response where we can not easily intervene with the browser (we would need to disable | ||
# auto-following of redirects). This test does hit the code, and proves that the authentication | ||
# is not broken by it. | ||
Scenario: When stepup.sfo.override_engine_entityid is configured, the the Issuer is updated | ||
Given feature "eb.stepup.sfo.override_engine_entityid" is enabled | ||
And the SP "SSO-SP" requires Stepup LoA "http://vm.openconext.org/assurance/loa2" | ||
When I log in at "SSO-SP" | ||
And I select "SSO-IdP" on the WAYF | ||
And I pass through EngineBlock | ||
# This is where the Issuer is overridden. See: \EngineBlock_Corto_ProxyServer::sendStepupAuthenticationRequest | ||
And I pass through the IdP | ||
And Stepup will successfully verify a user | ||
And I give my consent | ||
And I pass through EngineBlock | ||
Then the url should match "/functional-testing/SSO-SP/acs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs/stepup_callout.md file refers to this section for explanation of the Engineblock config. So I think this new setting should have at least a
#
comment like the ones above.