Skip to content

Commit

Permalink
[FrameworkBundle][Security] Create DIC aliases for security providers…
Browse files Browse the repository at this point in the history
… that are explicit services

The SecurityFactories expect security services to have a consistent naming convention, which was not the case for providers defined as `{ id: another.service }`.  These providers will now be aliased as "security.authentication.provider.[key]" and can be accessed in the same manner as other providers.
  • Loading branch information
jmikola authored and fabpot committed Jan 5, 2011
1 parent 1e27d43 commit 3ab82cb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
Expand Up @@ -363,7 +363,9 @@ protected function createUserDaoProvider($name, $provider, ContainerBuilder $con

// Existing DAO service provider
if (isset($provider['id'])) {
return array($provider['id'], $encoder);
$container->setAlias($name, $provider['id']);

return array($name, $encoder);
}

// Chain provider
Expand Down
Expand Up @@ -17,5 +17,8 @@
'doctrine' => array(
'entity' => array('class' => 'SecurityBundle:User', 'property' => 'username')
),
'service' => array(
'id' => 'user.manager',
),
)
));
Expand Up @@ -19,5 +19,7 @@
<provider name="doctrine">
<entity class="SecurityBundle:User" property="username" />
</provider>

<provider name="service" id="user.manager" />
</config>
</srv:container>
Expand Up @@ -12,3 +12,6 @@ security.config:

doctrine:
entity: { class: SecurityBundle:User, property: username }

service:
id: user.manager
Expand Up @@ -33,7 +33,7 @@ public function testUserProviders()
{
$container = $this->getContainer('provider');

$providers = array_values(array_filter(array_keys($container->getDefinitions()), function ($key) { return 0 === strpos($key, 'security.authentication.provider.'); }));
$providers = array_values(array_filter($container->getServiceIds(), function ($key) { return 0 === strpos($key, 'security.authentication.provider.'); }));

$this->assertEquals(array(
'security.authentication.provider.digest',
Expand All @@ -42,6 +42,7 @@ public function testUserProviders()
'security.authentication.provider.basic_b7f0cf21802ffc8b22cadbb255f07213',
'security.authentication.provider.basic_98e44377704554700e68c22094b51ca4',
'security.authentication.provider.doctrine',
'security.authentication.provider.service',
), $providers);
}

Expand Down

0 comments on commit 3ab82cb

Please sign in to comment.