Skip to content
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

Add feature flag to disable IdP-initiated authentication flow #1313

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ open_conext_engine_block:
eb.enable_sso_notification: "%feature_enable_sso_notification%"
eb.feature_enable_consent: "%feature_enable_consent%"
eb.enable_sso_session_cookie: "%feature_enable_sso_session_cookie%"
eb.feature_enable_idp_initiated_flow: "%feature_enable_idp_initiated_flow%"
eb.stepup.sfo.override_engine_entityid: "%feature_stepup_sfo_override_engine_entityid%"


Expand Down
1 change: 1 addition & 0 deletions app/config/parameters.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ parameters:
feature_block_user_on_violation: false
feature_enable_consent: true
feature_stepup_sfo_override_engine_entityid: false
feature_enable_idp_initiated_flow: true

##########################################################################################
## PROFILE SETTINGS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function __construct()
$this->setFeature(new Feature('eb.feature_enable_consent', true));
$this->setFeature(new Feature('eb.enable_sso_session_cookie', true));
$this->setFeature(new Feature('eb.stepup.sfo.override_engine_entityid', false));
$this->setFeature(new Feature('eb.feature_enable_idp_initiated_flow', true));
}

public function setFeature(Feature $feature): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
use OpenConext\EngineBlock\Service\RequestAccessMailer;
use OpenConext\EngineBlock\Validator\RequestValidator;
use OpenConext\EngineBlockBridge\ResponseFactory;
use OpenConext\EngineBlockBundle\Configuration\FeatureConfigurationInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Twig_Environment;

/**
Expand Down Expand Up @@ -74,6 +76,11 @@ class IdentityProviderController implements AuthenticationLoopThrottlingControll
*/
private $bindingValidator;

/**
* @var FeatureConfigurationInterface
*/
private $featureConfiguration;

public function __construct(
EngineBlock_ApplicationSingleton $engineBlockApplicationSingleton,
Twig_Environment $twig,
Expand All @@ -82,7 +89,8 @@ public function __construct(
RequestValidator $requestValidator,
RequestValidator $bindingValidator,
RequestValidator $unsolicitedRequestValidator,
AuthenticationStateHelperInterface $authenticationStateHelper
AuthenticationStateHelperInterface $authenticationStateHelper,
FeatureConfigurationInterface $featureConfiguration
) {
$this->engineBlockApplicationSingleton = $engineBlockApplicationSingleton;
$this->twig = $twig;
Expand All @@ -92,6 +100,7 @@ public function __construct(
$this->bindingValidator = $bindingValidator;
$this->unsolicitedRequestValidator = $unsolicitedRequestValidator;
$this->authenticationStateHelper = $authenticationStateHelper;
$this->featureConfiguration = $featureConfiguration;
}

/**
Expand Down Expand Up @@ -130,9 +139,14 @@ public function singleSignOnAction(Request $request, $keyId = null, $idpHash = n
* @param null|string $keyId
* @param null|string $idpHash
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
* @throws NotFoundHttpException If the IdP-initiated flow has been disabled by config
*/
public function unsolicitedSingleSignOnAction(Request $request, $keyId = null, $idpHash = null)
{
if (!$this->featureConfiguration->isEnabled('eb.feature_enable_idp_initiated_flow')) {
throw new NotFoundHttpException();
}

$this->unsolicitedRequestValidator->isValid($request);

$cortoAdapter = new EngineBlock_Corto_Adapter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
- "@engineblock.validator.saml_binding_validator"
- "@engineblock.validator.unsolicited_sso_request_validator"
- "@engineblock.service.authentication_state_helper"
- "@engineblock.features"

engineblock.controller.authentication.index:
class: OpenConext\EngineBlockBundle\Controller\IndexController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ Feature:
And the response should contain "Motivation for affiliation"
And the response should contain "Motivation for orcid"

Scenario: The user is presented with an institution provided consent text
Given I log in at "Dummy-SP"
And the IdP "Dummy-IdP" provides a consent message "Institutional privacy message" for SP "Dummy-SP"
And I pass through EngineBlock
And I pass through the IdP
Then the response should contain "Institutional privacy message"

Scenario: The user can reload the consent screen without error
Given I log in at "Dummy-SP"
And I pass through EngineBlock
Expand All @@ -95,6 +88,13 @@ Feature:
When I reload the page
Then the response should contain "Proceed to Dummy-SP"

Scenario: The user is presented with an institution provided consent text
Given I log in at "Dummy-SP"
And the IdP "Dummy-IdP" provides a consent message "Institutional privacy message" for SP "Dummy-SP"
And I pass through EngineBlock
And I pass through the IdP
Then the response should contain "Institutional privacy message"

Scenario: The user sees the identifier section when nameid is persistent
Given SP "Dummy-SP" uses the Persistent NameID format
And I log in at "Dummy-SP"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Feature:
In order to disable unsolicited single sign On
As an administrator
I want to be able to disable unsolicited login

Background:
Given an EngineBlock instance on "vm.openconext.org"
And feature "eb.feature_enable_idp_initiated_flow" is disabled
And no registered SPs
And no registered Idps
And an Identity Provider named "Dummy IdP"
And a Service Provider named "Dummy SP"

# The feature flag: eb.feature_enable_idp_initiated_flow can disable unsolicited login
# EB Shows a 404 page in that case as the entire HTTP route is blocked in that case
Scenario: Engine disallows unsolicited login
When An IdP initiated Single Sign on for SP "Dummy SP" is triggered by IdP "Dummy IdP"
Then I should see "404 - Page not found"
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,16 @@ services:
arguments:
- "@engineblock.mock_clients.mock_stepup_gateway"
- "@twig"

engineblock.controller.authentication.identity_provider:
class: OpenConext\EngineBlockBundle\Controller\IdentityProviderController
arguments:
- "@engineblock.compat.application"
- "@twig"
- "@engineblock.compat.logger"
- "@engineblock.service.request_access_mailer"
- "@engineblock.validator.sso_request_validator"
- "@engineblock.validator.saml_binding_validator"
- "@engineblock.validator.unsolicited_sso_request_validator"
- "@engineblock.service.authentication_state_helper"
- "@engineblock.functional_testing.fixture.features"