Skip to content

Commit

Permalink
[Security] removed 'security.authentication_provider' tag
Browse files Browse the repository at this point in the history
  • Loading branch information
schmittjoh authored and fabpot committed Feb 14, 2011
1 parent 9e6fc0a commit bc283f1
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 45 deletions.

This file was deleted.

Expand Up @@ -159,7 +159,7 @@ protected function addFirewallsSection($rootNode, array $factories)
->prototype('scalar')->end()
->end()
->end()
->booleanNode('anonymous')->end()
->booleanNode('anonymous')->defaultFalse()->end()
->arrayNode('switch_user')
->scalarNode('provider')->end()
->scalarNode('parameter')->defaultValue('_switch_user')->end()
Expand Down
Expand Up @@ -42,10 +42,6 @@ public function create(ContainerBuilder $container, $id, $config, $userProviderI
{
// authentication provider
$authProviderId = $this->createAuthProvider($container, $id, $config, $userProviderId);
$container
->getDefinition($authProviderId)
->addTag('security.authentication_provider')
;

// authentication listener
$listenerId = $this->createListener($container, $id, $config, $userProviderId);
Expand Down
Expand Up @@ -31,7 +31,6 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
->setDefinition($provider, new DefinitionDecorator('security.authentication.provider.dao'))
->setArgument(0, new Reference($userProvider))
->setArgument(2, $id)
->addTag('security.authentication_provider')
;

// listener
Expand Down
Expand Up @@ -31,7 +31,6 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
->setDefinition($provider, new DefinitionDecorator('security.authentication.provider.dao'))
->setArgument(0, new Reference($userProvider))
->setArgument(2, $id)
->addTag('security.authentication_provider')
;

// listener
Expand Down
Expand Up @@ -31,7 +31,6 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
->setDefinition($authProviderId, new DefinitionDecorator('security.authentication.provider.rememberme'))
->addArgument($config['key'])
->addArgument($id)
->addTag('security.authentication_provider')
;

// remember me services
Expand Down
Expand Up @@ -32,7 +32,6 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
->setDefinition($provider, new DefinitionDecorator('security.authentication.provider.pre_authenticated'))
->setArgument(0, new Reference($userProvider))
->addArgument($id)
->addTag('security.authentication_provider')
;

// listener
Expand Down
Expand Up @@ -175,9 +175,9 @@ protected function createFirewalls($config, ContainerBuilder $container)

// load firewall map
$mapDef = $container->getDefinition('security.firewall.map');
$map = array();
$map = $authenticationProviders = array();
foreach ($firewalls as $name => $firewall) {
list($matcher, $listeners, $exceptionListener) = $this->createFirewall($container, $name, $firewall, $providerIds, $factories);
list($matcher, $listeners, $exceptionListener) = $this->createFirewall($container, $name, $firewall, $authenticationProviders, $providerIds, $factories);

$contextId = 'security.firewall.map.context.'.$name;
$context = $container->setDefinition($contextId, new DefinitionDecorator('security.firewall.context'));
Expand All @@ -188,9 +188,18 @@ protected function createFirewalls($config, ContainerBuilder $container)
$map[$contextId] = $matcher;
}
$mapDef->setArgument(1, $map);

// add authentication providers to authentication manager
$authenticationProviders = array_map(function($id) {
return new Reference($id);
}, array_values(array_unique($authenticationProviders)));
$container
->getDefinition('security.authentication.manager')
->setArgument(0, $authenticationProviders)
;
}

protected function createFirewall(ContainerBuilder $container, $id, $firewall, $providerIds, array $factories)
protected function createFirewall(ContainerBuilder $container, $id, $firewall, &$authenticationProviders, $providerIds, array $factories)
{
// Matcher
$i = 0;
Expand Down Expand Up @@ -259,7 +268,7 @@ protected function createFirewall(ContainerBuilder $container, $id, $firewall, $
}

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

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

Expand Down Expand Up @@ -295,10 +304,9 @@ protected function createContextListener($container, $contextKey)
return $this->contextListeners[$contextKey] = $listenerId;
}

protected function createAuthenticationListeners($container, $id, $firewall, $defaultProvider, array $factories)
protected function createAuthenticationListeners($container, $id, $firewall, &$authenticationProviders, $defaultProvider, array $factories)
{
$listeners = array();
$providers = array();
$hasListeners = false;
$defaultEntryPoint = null;

Expand All @@ -312,7 +320,7 @@ protected function createAuthenticationListeners($container, $id, $firewall, $de
list($provider, $listenerId, $defaultEntryPoint) = $factory->create($container, $id, $firewall[$key], $userProvider, $defaultEntryPoint);

$listeners[] = new Reference($listenerId);
$providers[] = new Reference($provider);
$authenticationProviders[] = $provider;
$hasListeners = true;
}
}
Expand All @@ -321,14 +329,15 @@ protected function createAuthenticationListeners($container, $id, $firewall, $de
// Anonymous
if (isset($firewall['anonymous'])) {
$listeners[] = new Reference('security.authentication.listener.anonymous');
$authenticationProviders[] = 'security.authentication.provider.anonymous';
$hasListeners = true;
}

if (false === $hasListeners) {
throw new \LogicException(sprintf('No authentication listener registered for pattern "%s".', isset($firewall['pattern']) ? $firewall['pattern'] : ''));
}

return array($listeners, $providers, $defaultEntryPoint);
return array($listeners, $defaultEntryPoint);
}

protected function createEncoders($encoders, ContainerBuilder $container)
Expand Down
Expand Up @@ -54,7 +54,6 @@

<service id="security.authentication.provider.anonymous" class="%security.authentication.provider.anonymous%" public="false">
<argument>%security.anonymous.key%</argument>
<tag name="security.authentication_provider" />
</service>

<service id="security.authentication.retry_entry_point" class="%security.authentication.retry_entry_point.class%" public="false" />
Expand Down

0 comments on commit bc283f1

Please sign in to comment.