Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrated GuardAuthenticationManager in the SecurityBundle
- Loading branch information
Showing
8 changed files
with
187 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...Bundle/SecurityBundle/DependencyInjection/Security/Factory/CustomAuthenticatorFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; | ||
|
||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; | ||
use Symfony\Component\Config\Definition\Builder\NodeDefinition; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
class CustomAuthenticatorFactory implements AuthenticatorFactoryInterface, SecurityFactoryInterface | ||
{ | ||
public function create(ContainerBuilder $container, string $id, array $config, string $userProvider, ?string $defaultEntryPoint) | ||
{ | ||
throw new \LogicException('Custom authenticators are not supported when "security.enable_authenticator_manager" is not set to true.'); | ||
} | ||
|
||
public function getPosition(): string | ||
{ | ||
return 'pre_auth'; | ||
} | ||
|
||
public function getKey(): string | ||
{ | ||
return 'custom_authenticator'; | ||
} | ||
|
||
/** | ||
* @param ArrayNodeDefinition $builder | ||
*/ | ||
public function addConfiguration(NodeDefinition $builder) | ||
{ | ||
$builder | ||
->fixXmlConfig('service') | ||
->children() | ||
->arrayNode('services') | ||
->info('An array of service ids for all of your "authenticators"') | ||
->requiresAtLeastOneElement() | ||
->prototype('scalar')->end() | ||
->end() | ||
->end() | ||
; | ||
} | ||
|
||
public function createAuthenticator(ContainerBuilder $container, string $id, array $config, string $userProviderId): array | ||
{ | ||
return $config['services']; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...fony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardFactoryInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* @author Wouter de Jong <wouter@wouterj.nl> | ||
*/ | ||
interface GuardFactoryInterface | ||
{ | ||
/** | ||
* Creates the Guard service(s) for the provided configuration. | ||
* | ||
* @return string|string[] The Guard service ID(s) to be used by the firewall | ||
*/ | ||
public function createGuard(ContainerBuilder $container, string $id, array $config, string $userProviderId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/Symfony/Bundle/SecurityBundle/Resources/config/authenticators.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" ?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<services> | ||
<service id="security.authenticator.http_basic" | ||
class="Symfony\Component\Security\Core\Authentication\Authenticator\HttpBasicAuthenticator" | ||
abstract="true"> | ||
<argument type="abstract">realm name</argument> | ||
<argument type="abstract">user provider</argument> | ||
<argument type="service" id="security.encoder_factory" /> | ||
<argument type="service" id="logger" on-invalid="null" /> | ||
</service> | ||
</services> | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters