Skip to content

Commit 1e6600f

Browse files
committed
Extract confusing multi-line WAYF remember-choice conditions in SingleSignOn
# If applied, this commit will... Extract two multi-line boolean conditions in SingleSignOn into named local variables. # Why is this change needed? Prior to this change, both conditions mixed a multi-line function call or comparison with trailing || continuation lines indented deeper than the if(, which was flagged in review as hard to read ('broken indent?' and 'rewrite to human readable ifs'). # How does it address the issue? This change assigns each condition to a clearly named boolean ($legacyRememberChoiceAllowed, $notEligibleForRememberedIdp) before the if statement, with no change in behavior. # Provide links to any relevant tickets, articles or other resources #2091
1 parent 7aa2bce commit 1e6600f

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,12 @@ public function serve($serviceName, Request $httpRequest)
230230

231231
// Auto-select IdP when 'wayf.rememberChoice' feature is enabled and is allowed for the current request,
232232
// and the per-SP remembered-choice feature is not enabled.
233-
if ($container->getRememberChoice() === true
233+
$legacyRememberChoiceAllowed = $container->getRememberChoice() === true
234234
&& $runtime->isRememberChoicePerIdpEnabled() === false
235-
&& !($request->getForceAuthn() || $request->isDebugRequest())
236-
) {
235+
&& !$request->getForceAuthn()
236+
&& !$request->isDebugRequest();
237+
238+
if ($legacyRememberChoiceAllowed) {
237239
$cookies = $container->getSymfonyRequest()->cookies->all();
238240
if (array_key_exists('rememberchoice', $cookies)) {
239241
$remembered = json_decode($cookies['rememberchoice']);
@@ -482,14 +484,13 @@ protected function _sendAuthenticationRequestForRememberedIdpPerServiceProvider(
482484
$runtime = $application->getDiContainerRuntime();
483485
$log = $this->_server->getLogger();
484486

485-
if (!RememberedIdpCookie::isEnabledForServiceProvider(
487+
$notEligibleForRememberedIdp = !RememberedIdpCookie::isEnabledForServiceProvider(
486488
$container->getRememberChoice() === true,
487489
$runtime->isRememberChoicePerIdpEnabled(),
488490
$sp
489-
)
490-
|| $request->getForceAuthn()
491-
|| $request->isDebugRequest()
492-
) {
491+
) || $request->getForceAuthn() || $request->isDebugRequest();
492+
493+
if ($notEligibleForRememberedIdp) {
493494
return false;
494495
}
495496

0 commit comments

Comments
 (0)