<?php
namespace App\Service;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
class BaseFirewallMatcher implements RequestMatcherInterface
{
// Should only be matched on login page when user first arrives to GET the form, if already validated with one
// of the other three security providers, they will be checked against their respective firewalls.
public function matches(Request $request) : bool
{
$session = $request->getSession();
$oneValidated = $session->get("_security_one", null);
$twoValidated = $session->get("_security_two", null);
$threeValidated = $session->get("_security_three", null);
$iamValidated = $session->get("_security_iam", null);
// If already validated with another security provider
if ($oneValidated || $twoValidated || $threeValidated || $iamValidated) {
return false;
} else {
$url = $request->getPathInfo();
// If these three logins are not matched
if ($url != "/login_1_check" && $url != "/login_2_check" && $url != "/login_3_check" && $url != "/login_iam_check") {
return true;
}
return false;
}
}
}