Skip to content

Commit

Permalink
Configure firewall's kernel exception listener with configured entry …
Browse files Browse the repository at this point in the history
…point or a default entry point
  • Loading branch information
Reinier Kip authored and fabpot committed Dec 2, 2014
1 parent b604b0a commit b122262
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,10 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
}

// Determine default entry point
$defaultEntryPoint = isset($firewall['entry_point']) ? $firewall['entry_point'] : null;
$configuredEntryPoint = isset($firewall['entry_point']) ? $firewall['entry_point'] : null;

// Authentication listeners
list($authListeners, $defaultEntryPoint) = $this->createAuthenticationListeners($container, $id, $firewall, $authenticationProviders, $defaultProvider, $defaultEntryPoint);
list($authListeners, $defaultEntryPoint) = $this->createAuthenticationListeners($container, $id, $firewall, $authenticationProviders, $defaultProvider, $configuredEntryPoint);

$listeners = array_merge($listeners, $authListeners);

Expand All @@ -350,7 +350,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
$listeners[] = new Reference('security.access_listener');

// Exception listener
$exceptionListener = new Reference($this->createExceptionListener($container, $firewall, $id, $defaultEntryPoint));
$exceptionListener = new Reference($this->createExceptionListener($container, $firewall, $id, $configuredEntryPoint ?: $defaultEntryPoint));

return array($matcher, $listeners, $exceptionListener);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ public function testItUsesTheConfiguredEntryPointWhenUsingUnknownCredentials()
);
}

public function testItUsesTheConfiguredEntryPointFromTheExceptionListenerWithFormLoginAndNoCredentials()
{
$client = $this->createClient(array('test_case' => 'FirewallEntryPoint', 'root_config' => 'config_form_login.yml'));
$client->insulate();

$client->request('GET', '/secure/resource');

$this->assertEquals(
EntryPointStub::RESPONSE_TEXT,
$client->getResponse()->getContent(),
"Custom entry point wasn't started"
);
}

protected function setUp()
{
parent::setUp();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
imports:
- { resource: ./config.yml }

security:
firewalls:
secure:
pattern: ^/
form_login:
check_path: /login_check

0 comments on commit b122262

Please sign in to comment.