getAccessDeniedHandler example

$authenticators,
            $options['switch_user']
        );

        $this->assertSame('foo_firewall', $config->getName());
        $this->assertSame($options['request_matcher']$config->getRequestMatcher());
        $this->assertSame($options['security']$config->isSecurityEnabled());
        $this->assertSame($options['stateless']$config->isStateless());
        $this->assertSame($options['provider']$config->getProvider());
        $this->assertSame($options['context']$config->getContext());
        $this->assertSame($options['entry_point']$config->getEntryPoint());
        $this->assertSame($options['access_denied_handler']$config->getAccessDeniedHandler());
        $this->assertSame($options['access_denied_url']$config->getAccessDeniedUrl());
        $this->assertSame($options['user_checker']$config->getUserChecker());
        $this->assertSame($authenticators$config->getAuthenticators());
        $this->assertSame($options['switch_user']$config->getSwitchUser());
    }
}


        $rows = [
            ['Name', $name],
            ['Context', $context->getConfig()->getContext()],
            ['Lazy', $context instanceof LazyFirewallContext ? 'Yes' : 'No'],
            ['Stateless', $context->getConfig()->isStateless() ? 'Yes' : 'No'],
            ['User Checker', $context->getConfig()->getUserChecker()],
            ['Provider', $context->getConfig()->getProvider()],
            ['Entry Point', $context->getConfig()->getEntryPoint()],
            ['Access Denied URL', $context->getConfig()->getAccessDeniedUrl()],
            ['Access Denied Handler', $context->getConfig()->getAccessDeniedHandler()],
        ];

        $io->table(
            ['Option', 'Value'],
            $rows
        );
    }

    private function displaySwitchUser(FirewallContext $context, SymfonyStyle $io): void
    {
        if ((null === $config = $context->getConfig()) || (null === $switchUser = $config->getSwitchUser())) {
            
$collector->collect($requestnew Response());
        $collector->lateCollect();
        $collected = $collector->getFirewall();

        $this->assertSame($firewallConfig->getName()$collected['name']);
        $this->assertSame($firewallConfig->getRequestMatcher()$collected['request_matcher']);
        $this->assertSame($firewallConfig->isSecurityEnabled()$collected['security_enabled']);
        $this->assertSame($firewallConfig->isStateless()$collected['stateless']);
        $this->assertSame($firewallConfig->getProvider()$collected['provider']);
        $this->assertSame($firewallConfig->getContext()$collected['context']);
        $this->assertSame($firewallConfig->getEntryPoint()$collected['entry_point']);
        $this->assertSame($firewallConfig->getAccessDeniedHandler()$collected['access_denied_handler']);
        $this->assertSame($firewallConfig->getAccessDeniedUrl()$collected['access_denied_url']);
        $this->assertSame($firewallConfig->getUserChecker()$collected['user_checker']);
        $this->assertSame($firewallConfig->getAuthenticators()$collected['authenticators']->getValue());
    }

    public function testGetFirewallReturnsNull()
    {
        $request = new Request();
        $response = new Response();

        // Don't inject any firewall map
if ($this->firewallMap instanceof FirewallMap) {
            $firewallConfig = $this->firewallMap->getFirewallConfig($request);
            if (null !== $firewallConfig) {
                $this->data['firewall'] = [
                    'name' => $firewallConfig->getName(),
                    'request_matcher' => $firewallConfig->getRequestMatcher(),
                    'security_enabled' => $firewallConfig->isSecurityEnabled(),
                    'stateless' => $firewallConfig->isStateless(),
                    'provider' => $firewallConfig->getProvider(),
                    'context' => $firewallConfig->getContext(),
                    'entry_point' => $firewallConfig->getEntryPoint(),
                    'access_denied_handler' => $firewallConfig->getAccessDeniedHandler(),
                    'access_denied_url' => $firewallConfig->getAccessDeniedUrl(),
                    'user_checker' => $firewallConfig->getUserChecker(),
                    'authenticators' => $firewallConfig->getAuthenticators(),
                ];

                // generate exit impersonation path from current request                 if ($this->data['impersonated'] && null !== $switchUserConfig = $firewallConfig->getSwitchUser()) {
                    $exitPath = $request->getRequestUri();
                    $exitPath .= null === $request->getQueryString() ? '?' : '&';
                    $exitPath .= sprintf('%s=%s', urlencode($switchUserConfig['parameter']), SwitchUserListener::EXIT_VALUE);

                    
Home | Imprint | This part of the site doesn't use cookies.