Skip to content

Commit 1efb998

Browse files
committed
Remove quadruple wrong binding log
Prior to this change, when an SP used an unsupported ProtocolBinding in its AuthnRequest, EB would output 4x the same log message. This was the case because the log was very deep in the call tree AND the ACS lookup was performed twice in createEnhancedResponse(). This change first removes the duplicate ACS lookup, reducing the log message to 2x. But even then, logging at a very low level still caused duplicate messages. So the check was moved to the entry point (SingleSignOn::serve()) where the SP request is first received. Resolves #1807
1 parent 025f511 commit 1efb998

5 files changed

Lines changed: 37 additions & 9 deletions

File tree

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

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

19-
use OpenConext\EngineBlock\Logger\Message\AdditionalInfo;
20-
use OpenConext\EngineBlock\Metadata\Entity\IdentityProvider;
2119
use OpenConext\EngineBlock\Metadata\Entity\ServiceProvider;
2220
use OpenConext\EngineBlock\Metadata\Factory\Factory\ServiceProviderFactory;
2321
use OpenConext\EngineBlock\Metadata\Discovery;
2422
use OpenConext\EngineBlock\Metadata\X509\KeyPairFactory;
25-
use OpenConext\EngineBlockBundle\Exception\InvalidArgumentException as EngineBlockBundleInvalidArgumentException;
2623
use OpenConext\EngineBlockBundle\Service\DiscoverySelectionService;
2724
use SAML2\AuthnRequest;
25+
use SAML2\Constants;
2826
use SAML2\Response;
2927
use SAML2\XML\saml\Issuer;
3028
use Symfony\Component\HttpFoundation\Request;
@@ -104,6 +102,14 @@ public function serve($serviceName, Request $httpRequest)
104102
// Exposing entityId to be used when tracking the start of an authentication procedure
105103
$application->authenticationStateSpEntityId = $sp->entityId;
106104

105+
// EB will fall back to HTTP-POST
106+
$protocolBinding = $request->getProtocolBinding();
107+
if (!empty($protocolBinding) && $protocolBinding !== Constants::BINDING_HTTP_POST) {
108+
$log->notice(
109+
"ProtocolBinding '{$protocolBinding}' requested by Issuer '{$sp->entityId}' is not supported, ignoring..."
110+
);
111+
}
112+
107113
// Flush log if an SP in the requester chain has additional logging enabled
108114
$log->info("Determining whether service provider in chain requires additional logging");
109115

library/EngineBlock/Corto/ProxyServer.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -830,8 +830,7 @@ public function createEnhancedResponse(
830830
$subjectConfirmation->setSubjectConfirmationData($subjectConfirmationData);
831831

832832
// Confirm where we are sending it.
833-
$acs = $this->getRequestAssertionConsumer($request);
834-
$subjectConfirmationData->setRecipient($acs->location);
833+
$subjectConfirmationData->setRecipient($newResponse->getDestination());
835834

836835
// Confirm that this is in response to their AuthnRequest (unless, you know, it isn't).
837836
if (!$request->isUnsolicited()) {
@@ -964,7 +963,7 @@ public function getDefaultAssertionConsumer(ServiceProvider $serviceProvider)
964963
*
965964
* @param EngineBlock_Saml2_AuthnRequestAnnotationDecorator $request
966965
* @param ServiceProvider $serviceProvider
967-
* @return null|\OpenConext\EngineBlock\Metadata\IndexedService
966+
* @return null|\OpenConext\EngineBlock\Metadata\IndexedService|false
968967
*/
969968
public function getCustomAssertionConsumer(
970969
EngineBlock_Saml2_AuthnRequestAnnotationDecorator $request,
@@ -983,9 +982,6 @@ public function getCustomAssertionConsumer(
983982
}
984983

985984
if ($protocolBinding !== Constants::BINDING_HTTP_POST) {
986-
$this->_server->getLogger()->notice(
987-
"ProtocolBinding '{$protocolBinding}' requested by Issuer '{$serviceProvider->entityId}' is not supported, ignoring..."
988-
);
989985
return false;
990986
}
991987

src/OpenConext/EngineBlockFunctionalTestingBundle/Features/Bindings.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,12 @@ Feature:
118118
And I pass through the IdP
119119
Then the url should match "authentication/feedback/unsolicited-response"
120120
And I should see "Error - Sign-in could not be completed"
121+
122+
Scenario: EngineBlock falls back to HTTP-POST when an unsupported ProtocolBinding is requested
123+
Given the SP requests ProtocolBinding "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
124+
When I log in at "Dummy SP"
125+
And I pass through EngineBlock
126+
And I pass through the IdP
127+
And I give my consent
128+
And I pass through EngineBlock
129+
Then the url should match "functional-testing/Dummy%20SP/acs"

src/OpenConext/EngineBlockFunctionalTestingBundle/Features/Context/MockSpContext.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,18 @@ public function theSpUsesTheHttpRedirectBinding()
332332
$this->mockSpRegistry->save();
333333
}
334334

335+
/**
336+
* @Given /^the SP requests ProtocolBinding "([^"]*)"$/
337+
*/
338+
public function theSpRequestsProtocolBinding($binding)
339+
{
340+
$sp = $this->mockSpRegistry->getOnly();
341+
342+
$sp->setRequestedProtocolBinding($binding);
343+
344+
$this->mockSpRegistry->save();
345+
}
346+
335347
/**
336348
* @Given /^no registered SPs/
337349
*/

src/OpenConext/EngineBlockFunctionalTestingBundle/Mock/MockServiceProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ public function setAuthnRequestProxyCountTo($proxyCount)
133133
$this->descriptor->getExtensions()['SAMLRequest']->setProxyCount($proxyCount);
134134
}
135135

136+
public function setRequestedProtocolBinding(string $binding)
137+
{
138+
$this->descriptor->getExtensions()['SAMLRequest']->setProtocolBinding($binding);
139+
}
140+
136141
public function setAuthnRequestToPassive()
137142
{
138143
$this->descriptor->getExtensions()['SAMLRequest']->setIsPassive(true);

0 commit comments

Comments
 (0)