Skip to content

Commit 4966ea0

Browse files
authored
Merge pull request #876 from OpenConext/bugfix/transparant-acs-issue
Do not apply ValidateMfaAuthnContextClassRef filter for transparent use case
2 parents 3481396 + 7cc2e85 commit 4966ea0

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
use OpenConext\EngineBlock\Assert\Assertion;
20+
use OpenConext\EngineBlock\Metadata\TransparentMfaEntity;
2021
use Psr\Log\LoggerInterface;
2122

2223
/**
@@ -34,7 +35,8 @@ class EngineBlock_Corto_Filter_Command_ValidateMfaAuthnContextClassRef extends E
3435
public function execute()
3536
{
3637
$mfaEntity = $this->_identityProvider->getCoins()->mfaEntities()->findByEntityId($this->_serviceProvider->entityId);
37-
if (!$mfaEntity) {
38+
// SP's configured to pass auth context transparently are not checked for an expected (configured) class ref.
39+
if (!$mfaEntity || $mfaEntity instanceof TransparentMfaEntity) {
3840
return;
3941
}
4042

src/OpenConext/EngineBlockFunctionalTestingBundle/Features/MfaAuthnContextClassRef.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ Feature:
6565
And I pass through EngineBlock
6666
Then the url should match "functional-testing/SSO-IdP/sso"
6767
And the AuthnRequest to submit should match xpath '/samlp:AuthnRequest/samlp:RequestedAuthnContext/saml:AuthnContextClassRef[text()="http://my-very-own-context.example.com/level9"]'
68+
And I pass through the IdP
69+
And I give my consent
70+
And I pass through EngineBlock
71+
Then the url should match "/functional-testing/SSO-SP/acs"
6872

6973
Scenario: The SP provided authn method should NOT be set as AuthnContextClassRef if SP configured is not with transparent_authn_context
7074
Given the IdP "SSO-IdP" is configured for MFA authn method "not_configured_transparent_authn_context" for SP "SSO-SP"

tests/library/EngineBlock/Test/Corto/Filter/Command/ValidateMfaAuthnContextClassRefTest.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public function testMatchedAuthnContextClassRefShouldPass()
7878
$this->assertInstanceOf(EngineBlock_Corto_Filter_Command_Abstract::class, $verifier);
7979
}
8080

81-
8281
public function testMatchedAuthnMethodsReferenceAttributeShouldPass()
8382
{
8483
$response = $this->createTestResponse('urn:oasis:names:tc:SAML:2.0:ac:classes:Password', ['http://schemas.microsoft.com/claims/multipleauthn']);
@@ -95,7 +94,6 @@ public function testMatchedAuthnMethodsReferenceAttributeShouldPass()
9594
$this->assertInstanceOf(EngineBlock_Corto_Filter_Command_Abstract::class, $verifier);
9695
}
9796

98-
9997
public function testMatchedAuthnMethodsReferenceAttributeWithMultipleValuesShouldPass()
10098
{
10199
$response = $this->createTestResponse('urn:oasis:names:tc:SAML:2.0:ac:classes:Password', [
@@ -136,7 +134,6 @@ public function testMatchedAuthnclassrefAndAuthnMethodsReferenceAttributeWithMul
136134
$this->assertInstanceOf(EngineBlock_Corto_Filter_Command_Abstract::class, $verifier);
137135
}
138136

139-
140137
public function testNotMatchedAuthnContextClassRefShouldThrowException()
141138
{
142139
$this->expectException(EngineBlock_Corto_Exception_InvalidMfaAuthnContextClassRef::class);
@@ -181,6 +178,22 @@ public function testNotMatchedAuthnMethodsReferenceAttributeWithMultipleValuesSh
181178
$this->assertInstanceOf(EngineBlock_Corto_Filter_Command_Abstract::class, $verifier);
182179
}
183180

181+
public function testMatchedTransparentAuthnContextClassRefShouldPass()
182+
{
183+
$response = $this->createTestResponse('foobar.example.com');
184+
185+
$identityProvider = $this->createConfiguredSpIdpCombination('Test IdP', "Test SP", "transparent_authn_context");
186+
187+
$verifier = new EngineBlock_Corto_Filter_Command_ValidateMfaAuthnContextClassRef($this->logger);
188+
$verifier->setResponse($response);
189+
$verifier->setIdentityProvider($identityProvider);
190+
$verifier->setServiceProvider(new ServiceProvider('Test SP'));
191+
192+
$verifier->execute();
193+
194+
$this->assertInstanceOf(EngineBlock_Corto_Filter_Command_Abstract::class, $verifier);
195+
}
196+
184197
/**
185198
* @param string $idpEntity
186199
* @param string $spEntity

0 commit comments

Comments
 (0)