diff --git a/src/Generator.php b/src/Generator.php
index 3814c039b..3c0fe271a 100644
--- a/src/Generator.php
+++ b/src/Generator.php
@@ -12,7 +12,6 @@
namespace Symfony\Bundle\MakerBundle;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException;
use Symfony\Bundle\MakerBundle\Util\ClassNameDetails;
use Symfony\Bundle\MakerBundle\Util\PhpCompatUtil;
@@ -229,7 +228,6 @@ public function generateController(string $controllerClassName, string $controll
$parameters +
[
'generator' => $this->templateComponentGenerator,
- 'parent_class_name' => static::getControllerBaseClass()->getShortName(),
]
);
}
@@ -246,8 +244,13 @@ public function generateTemplate(string $targetPath, string $templateName, array
);
}
+ /**
+ * @deprecated MakerBundle only supports AbstractController::class. This method will be removed in the future.
+ */
public static function getControllerBaseClass(): ClassNameDetails
{
+ trigger_deprecation('symfony/maker-bundle', 'v1.41.0', 'MakerBundle only supports AbstractController. This method will be removed in the future.');
+
return new ClassNameDetails(AbstractController::class, '\\');
}
}
diff --git a/src/Maker/MakeAuthenticator.php b/src/Maker/MakeAuthenticator.php
index fc3c84014..d143a2906 100644
--- a/src/Maker/MakeAuthenticator.php
+++ b/src/Maker/MakeAuthenticator.php
@@ -11,6 +11,7 @@
namespace Symfony\Bundle\MakerBundle\Maker;
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\MakerBundle\ConsoleStyle;
use Symfony\Bundle\MakerBundle\DependencyBuilder;
use Symfony\Bundle\MakerBundle\Doctrine\DoctrineHelper;
@@ -23,6 +24,7 @@
use Symfony\Bundle\MakerBundle\Security\SecurityControllerBuilder;
use Symfony\Bundle\MakerBundle\Str;
use Symfony\Bundle\MakerBundle\Util\ClassSourceManipulator;
+use Symfony\Bundle\MakerBundle\Util\TemplateComponentGenerator;
use Symfony\Bundle\MakerBundle\Util\YamlManipulationFailedException;
use Symfony\Bundle\MakerBundle\Util\YamlSourceManipulator;
use Symfony\Bundle\MakerBundle\Validator;
@@ -33,12 +35,22 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Question\Question;
-use Symfony\Component\Form\Form;
-use Symfony\Component\HttpKernel\Kernel;
-use Symfony\Component\Security\Guard\Authenticator\AbstractFormLoginAuthenticator;
-use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
+use Symfony\Component\HttpFoundation\RedirectResponse;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\Routing\Annotation\Route;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
+use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
+use Symfony\Component\Security\Core\Exception\AuthenticationException;
+use Symfony\Component\Security\Core\Security;
+use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
+use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
+use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator;
+use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
-use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
+use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
+use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
+use Symfony\Component\Security\Http\Util\TargetPathTrait;
use Symfony\Component\Yaml\Yaml;
/**
@@ -53,17 +65,11 @@ final class MakeAuthenticator extends AbstractMaker
private const AUTH_TYPE_FORM_LOGIN = 'form-login';
private $fileManager;
-
private $configUpdater;
-
private $generator;
-
private $doctrineHelper;
-
private $securityControllerBuilder;
- private $useSecurity52 = false;
-
public function __construct(FileManager $fileManager, SecurityConfigUpdater $configUpdater, Generator $generator, DoctrineHelper $doctrineHelper, SecurityControllerBuilder $securityControllerBuilder)
{
$this->fileManager = $fileManager;
@@ -83,13 +89,13 @@ public static function getCommandDescription(): string
return 'Creates a Guard authenticator of different flavors';
}
- public function configureCommand(Command $command, InputConfiguration $inputConfig)
+ public function configureCommand(Command $command, InputConfiguration $inputConfig): void
{
$command
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeAuth.txt'));
}
- public function interact(InputInterface $input, ConsoleStyle $io, Command $command)
+ public function interact(InputInterface $input, ConsoleStyle $io, Command $command): void
{
if (!$this->fileManager->fileExists($path = 'config/packages/security.yaml')) {
throw new RuntimeCommandException('The file "config/packages/security.yaml" does not exist. This command requires that file to exist so that it can be updated.');
@@ -97,13 +103,8 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
$manipulator = new YamlSourceManipulator($this->fileManager->getFileContents($path));
$securityData = $manipulator->getData();
- // Determine if we should use new security features introduced in Symfony 5.2
- if ($securityData['security']['enable_authenticator_manager'] ?? false) {
- $this->useSecurity52 = true;
- }
-
- if ($this->useSecurity52 && !class_exists(UserBadge::class)) {
- throw new RuntimeCommandException('MakerBundle does not support generating authenticators using the new authenticator system before symfony/security-bundle 5.2. Please upgrade to 5.2 and try again.');
+ if (!($securityData['security']['enable_authenticator_manager'] ?? false)) {
+ throw new RuntimeCommandException('MakerBundle only supports the new authenticator based security system. See https://symfony.com/doc/current/security.html');
}
// authenticator type
@@ -124,14 +125,8 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
if (self::AUTH_TYPE_FORM_LOGIN === $input->getArgument('authenticator-type')) {
$neededDependencies = [TwigBundle::class => 'twig'];
- $missingPackagesMessage = 'Twig must be installed to display the login form.';
-
- if (Kernel::VERSION_ID < 40100) {
- $neededDependencies[Form::class] = 'symfony/form';
- $missingPackagesMessage = 'Twig and symfony/form must be installed to display the login form';
- }
+ $missingPackagesMessage = $this->addDependencies($neededDependencies, 'Twig must be installed to display the login form.');
- $missingPackagesMessage = $this->addDependencies($neededDependencies, $missingPackagesMessage);
if ($missingPackagesMessage) {
throw new RuntimeCommandException($missingPackagesMessage);
}
@@ -161,13 +156,6 @@ function ($answer) {
$command->addOption('entry-point', null, InputOption::VALUE_OPTIONAL);
- if (!$this->useSecurity52) {
- $input->setOption(
- 'entry-point',
- $interactiveSecurityHelper->guessEntryPoint($io, $securityData, $input->getArgument('authenticator-class'), $firewallName)
- );
- }
-
if (self::AUTH_TYPE_FORM_LOGIN === $input->getArgument('authenticator-type')) {
$command->addArgument('controller-class', InputArgument::REQUIRED);
$input->setArgument(
@@ -202,7 +190,7 @@ function ($answer) {
}
}
- public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator)
+ public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator): void
{
$manipulator = new YamlSourceManipulator($this->fileManager->getFileContents('config/packages/security.yaml'));
$securityData = $manipulator->getData();
@@ -220,7 +208,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
$entryPoint = $input->getOption('entry-point');
- if ($this->useSecurity52 && self::AUTH_TYPE_FORM_LOGIN !== $input->getArgument('authenticator-type')) {
+ if (self::AUTH_TYPE_FORM_LOGIN !== $input->getArgument('authenticator-type')) {
$entryPoint = false;
}
@@ -230,8 +218,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
$input->getOption('firewall-name'),
$entryPoint,
$input->getArgument('authenticator-class'),
- $input->hasArgument('logout-setup') ? $input->getArgument('logout-setup') : false,
- $this->useSecurity52
+ $input->hasArgument('logout-setup') ? $input->getArgument('logout-setup') : false
);
$generator->dumpFile($path, $newYaml);
$securityYamlUpdated = true;
@@ -262,22 +249,42 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
);
}
- private function generateAuthenticatorClass(array $securityData, string $authenticatorType, string $authenticatorClass, $userClass, $userNameField)
+ private function generateAuthenticatorClass(array $securityData, string $authenticatorType, string $authenticatorClass, $userClass, $userNameField): void
{
+ $useStatements = [
+ Request::class,
+ Response::class,
+ TokenInterface::class,
+ Passport::class,
+ ];
+
// generate authenticator class
if (self::AUTH_TYPE_EMPTY_AUTHENTICATOR === $authenticatorType) {
+ $emptyAuthUseStatements = array_merge($useStatements, [
+ AuthenticationException::class,
+ AbstractAuthenticator::class,
+ ]);
+
$this->generator->generateClass(
$authenticatorClass,
- sprintf('authenticator/%sEmptyAuthenticator.tpl.php', $this->useSecurity52 ? 'Security52' : ''),
- [
- 'provider_key_type_hint' => $this->getGuardProviderKeyTypeHint(),
- 'use_legacy_passport_interface' => $this->shouldUseLegacyPassportInterface(),
- ]
+ 'authenticator/EmptyAuthenticator.tpl.php',
+ ['use_statements' => TemplateComponentGenerator::generateUseStatements($emptyAuthUseStatements)]
);
return;
}
+ $useStatements = array_merge($useStatements, [
+ RedirectResponse::class,
+ UrlGeneratorInterface::class,
+ Security::class,
+ AbstractLoginFormAuthenticator::class,
+ CsrfTokenBadge::class,
+ UserBadge::class,
+ PasswordCredentials::class,
+ TargetPathTrait::class,
+ ]);
+
$userClassNameDetails = $this->generator->createClassNameDetails(
'\\'.$userClass,
'Entity\\'
@@ -285,8 +292,9 @@ private function generateAuthenticatorClass(array $securityData, string $authent
$this->generator->generateClass(
$authenticatorClass,
- sprintf('authenticator/%sLoginFormAuthenticator.tpl.php', $this->useSecurity52 ? 'Security52' : ''),
+ 'authenticator/LoginFormAuthenticator.tpl.php',
[
+ 'use_statements' => TemplateComponentGenerator::generateUseStatements($useStatements),
'user_fully_qualified_class_name' => trim($userClassNameDetails->getFullName(), '\\'),
'user_class_name' => $userClassNameDetails->getShortName(),
'username_field' => $userNameField,
@@ -294,13 +302,11 @@ private function generateAuthenticatorClass(array $securityData, string $authent
'username_field_var' => Str::asLowerCamelCase($userNameField),
'user_needs_encoder' => $this->userClassHasEncoder($securityData, $userClass),
'user_is_entity' => $this->doctrineHelper->isClassAMappedEntity($userClass),
- 'provider_key_type_hint' => $this->getGuardProviderKeyTypeHint(),
- 'use_legacy_passport_interface' => $this->shouldUseLegacyPassportInterface(),
]
);
}
- private function generateFormLoginFiles(string $controllerClass, string $userNameField, bool $logoutSetup)
+ private function generateFormLoginFiles(string $controllerClass, string $userNameField, bool $logoutSetup): void
{
$controllerClassNameDetails = $this->generator->createClassNameDetails(
$controllerClass,
@@ -309,9 +315,16 @@ private function generateFormLoginFiles(string $controllerClass, string $userNam
);
if (!class_exists($controllerClassNameDetails->getFullName())) {
+ $useStatements = [
+ AbstractController::class,
+ Route::class,
+ AuthenticationUtils::class,
+ ];
+
$controllerPath = $this->generator->generateController(
$controllerClassNameDetails->getFullName(),
- 'authenticator/EmptySecurityController.tpl.php'
+ 'authenticator/EmptySecurityController.tpl.php',
+ ['use_statements' => TemplateComponentGenerator::generateUseStatements($useStatements)]
);
$controllerSourceCode = $this->generator->getFileContentsForPendingOperation($controllerPath);
@@ -358,8 +371,7 @@ private function generateNextMessage(bool $securityYamlUpdated, string $authenti
'main',
null,
$authenticatorClass,
- $logoutSetup,
- $this->useSecurity52
+ $logoutSetup
);
$nextTexts[] = "- Your security.yaml could not be updated automatically. You'll need to add the following config manually:\n\n".$yamlExample;
}
@@ -371,11 +383,6 @@ private function generateNextMessage(bool $securityYamlUpdated, string $authenti
$nextTexts[] = sprintf('- Review %s::getUser() to make sure it matches your needs.', $authenticatorClass);
}
- // this only applies to Guard authentication AND if the user does not have a hasher configured
- if (!$this->useSecurity52 && !$this->userClassHasEncoder($securityData, $userClass)) {
- $nextTexts[] = sprintf('- Check the user\'s password in %s::checkCredentials().', $authenticatorClass);
- }
-
$nextTexts[] = '- Review & adapt the login template: '.$this->fileManager->getPathForTemplate('security/login.html.twig').'.';
}
@@ -396,7 +403,7 @@ private function userClassHasEncoder(array $securityData, string $userClass): bo
return $userNeedsEncoder;
}
- public function configureDependencies(DependencyBuilder $dependencies, InputInterface $input = null)
+ public function configureDependencies(DependencyBuilder $dependencies, InputInterface $input = null): void
{
$dependencies->addClassDependency(
SecurityBundle::class,
@@ -409,43 +416,4 @@ public function configureDependencies(DependencyBuilder $dependencies, InputInte
'yaml'
);
}
-
- /**
- * Calculates the type-hint used for the $provider argument (string or nothing) for Guard.
- */
- private function getGuardProviderKeyTypeHint(): string
- {
- // doesn't matter: this only applies to non-Guard authenticators
- if (!class_exists(AbstractFormLoginAuthenticator::class)) {
- return '';
- }
-
- $reflectionMethod = new \ReflectionMethod(AbstractFormLoginAuthenticator::class, 'onAuthenticationSuccess');
- $type = $reflectionMethod->getParameters()[2]->getType();
-
- if (!$type instanceof \ReflectionNamedType) {
- return '';
- }
-
- return sprintf('%s ', $type->getName());
- }
-
- private function shouldUseLegacyPassportInterface(): bool
- {
- // only applies to new authenticator security
- if (!$this->useSecurity52) {
- return false;
- }
-
- // legacy: checking for Symfony 5.2 & 5.3 before PassportInterface deprecation
- $class = new \ReflectionClass(AuthenticatorInterface::class);
- $method = $class->getMethod('authenticate');
-
- // 5.4 where return type is temporarily removed
- if (!$method->getReturnType()) {
- return false;
- }
-
- return PassportInterface::class === $method->getReturnType()->getName();
- }
}
diff --git a/src/Maker/MakeUser.php b/src/Maker/MakeUser.php
index d2a8a92d1..06ad85f57 100644
--- a/src/Maker/MakeUser.php
+++ b/src/Maker/MakeUser.php
@@ -32,9 +32,6 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\PasswordHasher\Hasher\NativePasswordHasher;
-use Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder;
-use Symfony\Component\Security\Core\Encoder\NativePasswordEncoder;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
@@ -76,7 +73,7 @@ public static function getCommandDescription(): string
return 'Creates a new security user class';
}
- public function configureCommand(Command $command, InputConfiguration $inputConf)
+ public function configureCommand(Command $command, InputConfiguration $inputConfig): void
{
$command
->addArgument('name', InputArgument::OPTIONAL, 'The name of the security user class (e.g. User>)')
@@ -86,10 +83,10 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
->addOption('use-argon2', null, InputOption::VALUE_NONE, 'Use the Argon2i password encoder? (deprecated)')
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeUser.txt'));
- $inputConf->setArgumentAsNonInteractive('name');
+ $inputConfig->setArgumentAsNonInteractive('name');
}
- public function interact(InputInterface $input, ConsoleStyle $io, Command $command)
+ public function interact(InputInterface $input, ConsoleStyle $io, Command $command): void
{
if (null === $input->getArgument('name')) {
$name = $io->ask(
@@ -120,21 +117,9 @@ class_exists(DoctrineBundle::class)
$io->text('Will this app need to hash/check user passwords? Choose No if passwords are not needed or will be checked/hashed by some other system (e.g. a single sign-on server).');
$userWillHavePassword = $io->confirm('Does this app need to hash/check user passwords?');
$input->setOption('with-password', $userWillHavePassword);
-
- $symfonyGte53 = class_exists(NativePasswordHasher::class);
- if ($symfonyGte53) {
- return;
- }
-
- if ($userWillHavePassword && !class_exists(NativePasswordEncoder::class) && Argon2iPasswordEncoder::isSupported()) {
- $io->writeln('The newer Argon2i password hasher requires PHP 7.2, libsodium or paragonie/sodium_compat. Your system DOES support this algorithm.');
- $io->writeln('You should use Argon2i unless your production system will not support it.');
- $useArgon2Encoder = $io->confirm('Use Argon2i as your password hasher (bcrypt will be used otherwise)?');
- $input->setOption('use-argon2', $useArgon2Encoder);
- }
}
- public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator)
+ public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator): void
{
$userClassConfiguration = new UserClassConfiguration(
$input->getOption('is-entity'),
@@ -248,7 +233,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
$io->text($nextSteps);
}
- public function configureDependencies(DependencyBuilder $dependencies, InputInterface $input = null)
+ public function configureDependencies(DependencyBuilder $dependencies, InputInterface $input = null): void
{
// checking for SecurityBundle guarantees security.yaml is present
$dependencies->addClassDependency(
diff --git a/src/Resources/skeleton/authenticator/EmptyAuthenticator.tpl.php b/src/Resources/skeleton/authenticator/EmptyAuthenticator.tpl.php
index 234b77796..bfa1e7fc1 100644
--- a/src/Resources/skeleton/authenticator/EmptyAuthenticator.tpl.php
+++ b/src/Resources/skeleton/authenticator/EmptyAuthenticator.tpl.php
@@ -2,52 +2,38 @@
namespace = $namespace ?>;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
-use Symfony\Component\Security\Core\Exception\AuthenticationException;
-use Symfony\Component\Security\Core\User\UserInterface;
-use Symfony\Component\Security\Core\User\UserProviderInterface;
-use Symfony\Component\Security\Guard\AbstractGuardAuthenticator;
+= $use_statements; ?>
-class = $class_name ?> extends AbstractGuardAuthenticator
+class = $class_name ?> extends AbstractAuthenticator
{
- public function supports(Request $request)
+ public function supports(Request $request): ?bool
{
- // todo
+ // TODO: Implement supports() method.
}
- public function getCredentials(Request $request)
+ public function authenticate(Request $request): Passport
{
- // todo
+ // TODO: Implement authenticate() method.
}
- public function getUser($credentials, UserProviderInterface $userProvider)
+ public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
{
- // todo
+ // TODO: Implement onAuthenticationSuccess() method.
}
- public function checkCredentials($credentials, UserInterface $user)
+ public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
{
- // todo
+ // TODO: Implement onAuthenticationFailure() method.
}
- public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
- {
- // todo
- }
-
- public function onAuthenticationSuccess(Request $request, TokenInterface $token, = $provider_key_type_hint ?>$providerKey)
- {
- // todo
- }
-
- public function start(Request $request, AuthenticationException $authException = null)
- {
- // todo
- }
-
- public function supportsRememberMe()
- {
- // todo
- }
+// public function start(Request $request, AuthenticationException $authException = null): Response
+// {
+// /*
+// * If you would like this class to control what happens when an anonymous user accesses a
+// * protected page (e.g. redirect to /login), uncomment this method and make this class
+// * implement Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface.
+// *
+// * For more details, see https://symfony.com/doc/current/security/experimental_authenticators.html#configuring-the-authentication-entry-point
+// */
+// }
}
diff --git a/src/Resources/skeleton/authenticator/EmptySecurityController.tpl.php b/src/Resources/skeleton/authenticator/EmptySecurityController.tpl.php
index 2a5fa186e..1813dde30 100644
--- a/src/Resources/skeleton/authenticator/EmptySecurityController.tpl.php
+++ b/src/Resources/skeleton/authenticator/EmptySecurityController.tpl.php
@@ -2,10 +2,8 @@
namespace = $namespace ?>;
-use Symfony\Bundle\FrameworkBundle\Controller\= $parent_class_name; ?>;
-use Symfony\Component\Routing\Annotation\Route;
-use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
+= $use_statements; ?>
-class = $class_name; ?> extends = $parent_class_name; ?>= "\n" ?>
+class = $class_name; ?> extends AbstractController
{
}
diff --git a/src/Resources/skeleton/authenticator/LoginFormAuthenticator.tpl.php b/src/Resources/skeleton/authenticator/LoginFormAuthenticator.tpl.php
index 07ed740be..fa960f107 100644
--- a/src/Resources/skeleton/authenticator/LoginFormAuthenticator.tpl.php
+++ b/src/Resources/skeleton/authenticator/LoginFormAuthenticator.tpl.php
@@ -2,112 +2,48 @@
namespace = $namespace ?>;
-= $user_is_entity ? "use $user_fully_qualified_class_name;\n" : null ?>
-= $user_is_entity ? "use Doctrine\\ORM\\EntityManagerInterface;\n" : null ?>
-use Symfony\Component\HttpFoundation\RedirectResponse;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
-use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
-= $user_needs_encoder ? "use Symfony\\Component\\Security\\Core\\Encoder\\UserPasswordEncoderInterface;\n" : null ?>
-use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException;
-use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
-use Symfony\Component\Security\Core\Security;
-use Symfony\Component\Security\Core\User\UserInterface;
-use Symfony\Component\Security\Core\User\UserProviderInterface;
-use Symfony\Component\Security\Csrf\CsrfToken;
-use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
-use Symfony\Component\Security\Guard\Authenticator\AbstractFormLoginAuthenticator;
-= ($password_authenticated = $user_needs_encoder && interface_exists('Symfony\Component\Security\Guard\PasswordAuthenticatedInterface')) ? "use Symfony\Component\Security\Guard\PasswordAuthenticatedInterface;\n" : '' ?>
-use Symfony\Component\Security\Http\Util\TargetPathTrait;
+= $use_statements; ?>
-class = $class_name; ?> extends AbstractFormLoginAuthenticator= $password_authenticated ? " implements PasswordAuthenticatedInterface\n" : "\n" ?>
+class = $class_name; ?> extends AbstractLoginFormAuthenticator
{
use TargetPathTrait;
public const LOGIN_ROUTE = 'app_login';
-= $user_is_entity ? " private \$entityManager;\n" : null ?>
- private $urlGenerator;
- private $csrfTokenManager;
-= $user_needs_encoder ? " private \$passwordEncoder;\n" : null ?>
+ private = $use_typed_properties ? 'UrlGeneratorInterface ' : null ?>$urlGenerator;
- public function __construct(= $user_is_entity ? 'EntityManagerInterface $entityManager, ' : null ?>UrlGeneratorInterface $urlGenerator, CsrfTokenManagerInterface $csrfTokenManager= $user_needs_encoder ? ', UserPasswordEncoderInterface $passwordEncoder' : null ?>)
+ public function __construct(UrlGeneratorInterface $urlGenerator)
{
-= $user_is_entity ? " \$this->entityManager = \$entityManager;\n" : null ?>
$this->urlGenerator = $urlGenerator;
- $this->csrfTokenManager = $csrfTokenManager;
-= $user_needs_encoder ? " \$this->passwordEncoder = \$passwordEncoder;\n" : null ?>
}
- public function supports(Request $request)
+ public function authenticate(Request $request): Passport
{
- return self::LOGIN_ROUTE === $request->attributes->get('_route')
- && $request->isMethod('POST');
- }
-
- public function getCredentials(Request $request)
- {
- $credentials = [
- '= $username_field ?>' => $request->request->get('= $username_field ?>'),
- 'password' => $request->request->get('password'),
- 'csrf_token' => $request->request->get('_csrf_token'),
- ];
- $request->getSession()->set(
- Security::LAST_USERNAME,
- $credentials['= $username_field ?>']
- );
-
- return $credentials;
- }
-
- public function getUser($credentials, UserProviderInterface $userProvider)
- {
- $token = new CsrfToken('authenticate', $credentials['csrf_token']);
- if (!$this->csrfTokenManager->isTokenValid($token)) {
- throw new InvalidCsrfTokenException();
- }
+ $= $username_field_var ?> = $request->request->get('= $username_field ?>', '');
- = $user_is_entity ? "\$user = \$this->entityManager->getRepository($user_class_name::class)->findOneBy(['$username_field' => \$credentials['$username_field']]);\n"
- : "// Load / create our user however you need.
- // You can do this by calling the user provider, or with custom logic here.
- \$user = \$userProvider->loadUserByUsername(\$credentials['$username_field']);\n"; ?>
+ $request->getSession()->set(Security::LAST_USERNAME, $= $username_field_var ?>);
- if (!$user) {
- throw new UsernameNotFoundException('= ucfirst($username_field_label) ?> could not be found.');
- }
-
- return $user;
- }
-
- public function checkCredentials($credentials, UserInterface $user)
- {
- = $user_needs_encoder ? "return \$this->passwordEncoder->isPasswordValid(\$user, \$credentials['password']);\n"
- : "// Check the user's password or other credentials and return true or false
- // If there are no credentials to check, you can just return true
- throw new \Exception('TODO: check the credentials inside '.__FILE__);\n" ?>
- }
-
-
- /**
- * Used to upgrade (rehash) the user's password automatically over time.
- */
- public function getPassword($credentials): ?string
- {
- return $credentials['password'];
+ return new Passport(
+ new UserBadge($= $username_field_var ?>),
+ new PasswordCredentials($request->request->get('password', '')),
+ [
+ new CsrfTokenBadge('authenticate', $request->request->get('_csrf_token')),
+ ]
+ );
}
-
- public function onAuthenticationSuccess(Request $request, TokenInterface $token, = $provider_key_type_hint ?>$providerKey)
+ public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
{
- if ($targetPath = $this->getTargetPath($request->getSession(), $providerKey)) {
+ if ($targetPath = $this->getTargetPath($request->getSession(), $firewallName)) {
return new RedirectResponse($targetPath);
}
- // For example : return new RedirectResponse($this->urlGenerator->generate('some_route'));
+ // For example:
+ // return new RedirectResponse($this->urlGenerator->generate('some_route'));
throw new \Exception('TODO: provide a valid redirect inside '.__FILE__);
}
- protected function getLoginUrl()
+ protected function getLoginUrl(Request $request): string
{
return $this->urlGenerator->generate(self::LOGIN_ROUTE);
}
diff --git a/src/Resources/skeleton/authenticator/Security52EmptyAuthenticator.tpl.php b/src/Resources/skeleton/authenticator/Security52EmptyAuthenticator.tpl.php
deleted file mode 100644
index 204aa9913..000000000
--- a/src/Resources/skeleton/authenticator/Security52EmptyAuthenticator.tpl.php
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-namespace ;
-
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
-use Symfony\Component\Security\Core\Exception\AuthenticationException;
-use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
-use = $use_legacy_passport_interface ? 'Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\PassportInterface' : 'Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\Passport' ?>;
-
-class extends AbstractAuthenticator
-{
- public function supports(Request $request): ?bool
- {
- // TODO: Implement supports() method.
- }
-
- public function authenticate(Request $request): = ($use_legacy_passport_interface ? 'PassportInterface' : 'Passport') . "\n" ?>
- {
- // TODO: Implement authenticate() method.
- }
-
- public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
- {
- // TODO: Implement onAuthenticationSuccess() method.
- }
-
- public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
- {
- // TODO: Implement onAuthenticationFailure() method.
- }
-
-// public function start(Request $request, AuthenticationException $authException = null): Response
-// {
-// /*
-// * If you would like this class to control what happens when an anonymous user accesses a
-// * protected page (e.g. redirect to /login), uncomment this method and make this class
-// * implement Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface.
-// *
-// * For more details, see https://symfony.com/doc/current/security/experimental_authenticators.html#configuring-the-authentication-entry-point
-// */
-// }
-}
diff --git a/src/Resources/skeleton/authenticator/Security52LoginFormAuthenticator.tpl.php b/src/Resources/skeleton/authenticator/Security52LoginFormAuthenticator.tpl.php
deleted file mode 100644
index 36105c44e..000000000
--- a/src/Resources/skeleton/authenticator/Security52LoginFormAuthenticator.tpl.php
+++ /dev/null
@@ -1,62 +0,0 @@
-= "
-
-namespace = $namespace ?>;
-
-use Symfony\Component\HttpFoundation\RedirectResponse;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
-use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
-use Symfony\Component\Security\Core\Security;
-use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator;
-use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge;
-use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
-use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
-use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
-= $use_legacy_passport_interface ? 'use Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\PassportInterface;'."\n" : '' ?>
-use Symfony\Component\Security\Http\Util\TargetPathTrait;
-
-class = $class_name; ?> extends AbstractLoginFormAuthenticator
-{
- use TargetPathTrait;
-
- public const LOGIN_ROUTE = 'app_login';
-
- private = $use_typed_properties ? 'UrlGeneratorInterface ' : null ?>$urlGenerator;
-
- public function __construct(UrlGeneratorInterface $urlGenerator)
- {
- $this->urlGenerator = $urlGenerator;
- }
-
- public function authenticate(Request $request): = ($use_legacy_passport_interface ? 'PassportInterface' : 'Passport') . "\n" ?>
- {
- $= $username_field_var ?> = $request->request->get('= $username_field ?>', '');
-
- $request->getSession()->set(Security::LAST_USERNAME, $= $username_field_var ?>);
-
- return new Passport(
- new UserBadge($= $username_field_var ?>),
- new PasswordCredentials($request->request->get('password', '')),
- [
- new CsrfTokenBadge('authenticate', $request->request->get('_csrf_token')),
- ]
- );
- }
-
- public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
- {
- if ($targetPath = $this->getTargetPath($request->getSession(), $firewallName)) {
- return new RedirectResponse($targetPath);
- }
-
- // For example:
- // return new RedirectResponse($this->urlGenerator->generate('some_route'));
- throw new \Exception('TODO: provide a valid redirect inside '.__FILE__);
- }
-
- protected function getLoginUrl(Request $request): string
- {
- return $this->urlGenerator->generate(self::LOGIN_ROUTE);
- }
-}
diff --git a/src/Resources/skeleton/controller/Controller.tpl.php b/src/Resources/skeleton/controller/Controller.tpl.php
index 0c33ca345..49a8e1338 100644
--- a/src/Resources/skeleton/controller/Controller.tpl.php
+++ b/src/Resources/skeleton/controller/Controller.tpl.php
@@ -2,11 +2,11 @@
namespace = $namespace; ?>;
-use Symfony\Bundle\FrameworkBundle\Controller\= $parent_class_name; ?>;
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
-class = $class_name; ?> extends = $parent_class_name; ?>= "\n" ?>
+class = $class_name; ?> extends AbstractController
{
= $generator->generateRouteForControllerMethod($route_path, $route_name); ?>
public function index(): Response
diff --git a/src/Resources/skeleton/crud/controller/Controller.tpl.php b/src/Resources/skeleton/crud/controller/Controller.tpl.php
index ebc87499b..e69fa2c6b 100644
--- a/src/Resources/skeleton/crud/controller/Controller.tpl.php
+++ b/src/Resources/skeleton/crud/controller/Controller.tpl.php
@@ -9,7 +9,7 @@
use Doctrine\ORM\EntityManagerInterface;
-use Symfony\Bundle\FrameworkBundle\Controller\= $parent_class_name ?>;
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@@ -21,7 +21,7 @@
* @Route("= $route_path ?>")
*/
-class = $class_name ?> extends = $parent_class_name; ?>= "\n" ?>
+class = $class_name ?> extends AbstractController
{
= $generator->generateRouteForControllerMethod('/', sprintf('%s_index', $route_name), ['GET']) ?>
diff --git a/src/Resources/skeleton/registration/RegistrationController.tpl.php b/src/Resources/skeleton/registration/RegistrationController.tpl.php
index de8f192d8..431e93fc8 100644
--- a/src/Resources/skeleton/registration/RegistrationController.tpl.php
+++ b/src/Resources/skeleton/registration/RegistrationController.tpl.php
@@ -4,7 +4,7 @@
= $use_statements; ?>
-class = $class_name; ?> extends = $parent_class_name; ?>= "\n" ?>
+class = $class_name; ?> extends AbstractController
{
private = $generator->getPropertyType($email_verifier_class_details) ?>$emailVerifier;
diff --git a/src/Security/InteractiveSecurityHelper.php b/src/Security/InteractiveSecurityHelper.php
index 19770edaa..cc4cf276f 100644
--- a/src/Security/InteractiveSecurityHelper.php
+++ b/src/Security/InteractiveSecurityHelper.php
@@ -11,7 +11,6 @@
namespace Symfony\Bundle\MakerBundle\Security;
-use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException;
use Symfony\Bundle\MakerBundle\Str;
use Symfony\Bundle\MakerBundle\Validator;
use Symfony\Component\Console\Style\SymfonyStyle;
@@ -46,43 +45,6 @@ function ($item) {
);
}
- public function guessEntryPoint(SymfonyStyle $io, array $securityData, string $authenticatorClass, string $firewallName)
- {
- if (!isset($securityData['security'])) {
- $securityData['security'] = [];
- }
-
- if (!isset($securityData['security']['firewalls'])) {
- $securityData['security']['firewalls'] = [];
- }
-
- $firewalls = $securityData['security']['firewalls'];
- if (!isset($firewalls[$firewallName])) {
- throw new RuntimeCommandException(sprintf('Firewall "%s" does not exist', $firewallName));
- }
-
- if (!isset($firewalls[$firewallName]['guard'])
- || !isset($firewalls[$firewallName]['guard']['authenticators'])
- || !$firewalls[$firewallName]['guard']['authenticators']
- || isset($firewalls[$firewallName]['guard']['entry_point'])) {
- return null;
- }
-
- $authenticators = $firewalls[$firewallName]['guard']['authenticators'];
- $authenticators[] = $authenticatorClass;
-
- return $io->choice(
- 'The entry point for your firewall is what should happen when an anonymous user tries to access
-a protected page. For example, a common "entry point" behavior is to redirect to the login page.
-The "entry point" behavior is controlled by the start() method on your authenticator.
-However, you will now have multiple authenticators. You need to choose which authenticator\'s
-start() method should be used as the entry point (the start() method on all other
-authenticators will be ignored, and can be blank.',
- $authenticators,
- current($authenticators)
- );
- }
-
public function guessUserClass(SymfonyStyle $io, array $providers, string $questionText = null): string
{
if (1 === \count($providers) && isset(current($providers)['entity'])) {
diff --git a/src/Security/SecurityConfigUpdater.php b/src/Security/SecurityConfigUpdater.php
index 12a2e3a1c..cede8530a 100644
--- a/src/Security/SecurityConfigUpdater.php
+++ b/src/Security/SecurityConfigUpdater.php
@@ -61,7 +61,7 @@ public function updateForUserClass(string $yamlSource, UserClassConfiguration $u
return $contents;
}
- public function updateForAuthenticator(string $yamlSource, string $firewallName, $chosenEntryPoint, string $authenticatorClass, bool $logoutSetup, bool $useSecurity52): string
+ public function updateForAuthenticator(string $yamlSource, string $firewallName, $chosenEntryPoint, string $authenticatorClass, bool $logoutSetup): string
{
$this->manipulator = new YamlSourceManipulator($yamlSource);
@@ -82,50 +82,30 @@ public function updateForAuthenticator(string $yamlSource, string $firewallName,
}
if (!isset($newData['security']['firewalls'][$firewallName])) {
- if ($useSecurity52) {
- $newData['security']['firewalls'][$firewallName] = ['lazy' => true];
- } else {
- $newData['security']['firewalls'][$firewallName] = ['anonymous' => 'lazy'];
- }
+ $newData['security']['firewalls'][$firewallName] = ['lazy' => true];
}
$firewall = $newData['security']['firewalls'][$firewallName];
- if ($useSecurity52) {
- if (isset($firewall['custom_authenticator'])) {
- if (\is_array($firewall['custom_authenticator'])) {
- $firewall['custom_authenticator'][] = $authenticatorClass;
- } else {
- $stringValue = $firewall['custom_authenticator'];
- $firewall['custom_authenticator'] = [];
- $firewall['custom_authenticator'][] = $stringValue;
- $firewall['custom_authenticator'][] = $authenticatorClass;
- }
+ if (isset($firewall['custom_authenticator'])) {
+ if (\is_array($firewall['custom_authenticator'])) {
+ $firewall['custom_authenticator'][] = $authenticatorClass;
} else {
- $firewall['custom_authenticator'] = $authenticatorClass;
- }
-
- if (!isset($firewall['entry_point']) && $chosenEntryPoint) {
- $firewall['entry_point_empty_line'] = $this->manipulator->createEmptyLine();
- $firewall['entry_point_comment'] = $this->manipulator->createCommentLine(
- ' the entry_point start() method determines what happens when an anonymous user accesses a protected page'
- );
- $firewall['entry_point'] = $authenticatorClass;
+ $stringValue = $firewall['custom_authenticator'];
+ $firewall['custom_authenticator'] = [];
+ $firewall['custom_authenticator'][] = $stringValue;
+ $firewall['custom_authenticator'][] = $authenticatorClass;
}
} else {
- if (!isset($firewall['guard'])) {
- $firewall['guard'] = [];
- }
-
- if (!isset($firewall['guard']['authenticators'])) {
- $firewall['guard']['authenticators'] = [];
- }
-
- $firewall['guard']['authenticators'][] = $authenticatorClass;
+ $firewall['custom_authenticator'] = $authenticatorClass;
+ }
- if (\count($firewall['guard']['authenticators']) > 1) {
- $firewall['guard']['entry_point'] = $chosenEntryPoint ?? current($firewall['guard']['authenticators']);
- }
+ if (!isset($firewall['entry_point']) && $chosenEntryPoint) {
+ $firewall['entry_point_empty_line'] = $this->manipulator->createEmptyLine();
+ $firewall['entry_point_comment'] = $this->manipulator->createCommentLine(
+ ' the entry_point start() method determines what happens when an anonymous user accesses a protected page'
+ );
+ $firewall['entry_point'] = $authenticatorClass;
}
if (!isset($firewall['logout']) && $logoutSetup) {
diff --git a/tests/Maker/MakeAuthenticatorTest.php b/tests/Maker/MakeAuthenticatorTest.php
index a35141520..d24cbebc3 100644
--- a/tests/Maker/MakeAuthenticatorTest.php
+++ b/tests/Maker/MakeAuthenticatorTest.php
@@ -15,7 +15,6 @@
use Symfony\Bundle\MakerBundle\Test\MakerTestCase;
use Symfony\Bundle\MakerBundle\Test\MakerTestRunner;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
-use Symfony\Component\Security\Core\User\UserInterface;
class MakeAuthenticatorTest extends MakerTestCase
{
@@ -24,10 +23,9 @@ protected function getMakerClass(): string
return MakeAuthenticator::class;
}
- public function getTestDetails()
+ public function getTestDetails(): \Generator
{
yield 'auth_empty_one_firewall' => [$this->createMakerTest()
- ->addRequiredPackageVersion('symfony/security-bundle', '>=5.2')
->run(function (MakerTestRunner $runner) {
$output = $runner->runMaker([
// authenticator type => empty-auth
@@ -47,7 +45,6 @@ public function getTestDetails()
];
yield 'auth_empty_multiple_firewalls' => [$this->createMakerTest()
- ->addRequiredPackageVersion('symfony/security-bundle', '>=5.2')
->run(function (MakerTestRunner $runner) {
$runner->modifyYamlFile('config/packages/security.yaml', function (array $config) {
$config['security']['firewalls']['second']['lazy'] = true;
@@ -74,7 +71,6 @@ public function getTestDetails()
];
yield 'auth_empty_existing_authenticator' => [$this->createMakerTest()
- ->addRequiredPackageVersion('symfony/security-bundle', '>=5.2')
->run(function (MakerTestRunner $runner) {
$runner->copy(
'make-auth/BlankAuthenticator.php',
@@ -108,7 +104,6 @@ public function getTestDetails()
];
yield 'auth_empty_multiple_firewalls_existing_authenticator' => [$this->createMakerTest()
- ->addRequiredPackageVersion('symfony/security-bundle', '>=5.2')
->run(function (MakerTestRunner $runner) {
$runner->copy(
'make-auth/BlankAuthenticator.php',
@@ -173,7 +168,6 @@ public function getTestDetails()
];
yield 'auth_login_form_no_entity_custom_username_field' => [$this->createMakerTest()
- ->addRequiredPackageVersion('symfony/security-bundle', '>=5.2')
->addExtraDependencies('doctrine/annotations', 'twig', 'symfony/form')
->run(function (MakerTestRunner $runner) {
$this->makeUser($runner, 'userEmail', false);
@@ -203,7 +197,6 @@ public function getTestDetails()
];
yield 'auth_login_form_user_not_entity_with_hasher' => [$this->createMakerTest()
- ->addRequiredPackageVersion('symfony/security-bundle', '>=5.2')
->addExtraDependencies('doctrine/annotations', 'twig', 'symfony/form')
->run(function (MakerTestRunner $runner) {
$this->makeUser($runner, 'email', false);
@@ -223,7 +216,6 @@ public function getTestDetails()
];
yield 'auth_login_form_existing_controller' => [$this->createMakerTest()
- ->addRequiredPackageVersion('symfony/security-bundle', '>=5.2')
->addExtraDependencies('doctrine', 'twig', 'symfony/form')
->run(function (MakerTestRunner $runner) {
$this->makeUser($runner, 'email');
@@ -248,7 +240,6 @@ public function getTestDetails()
];
yield 'auth_login_form_user_entity_with_logout' => [$this->createMakerTest()
- ->addRequiredPackageVersion('symfony/security-bundle', '>=5.2')
->addExtraDependencies('doctrine', 'twig', 'symfony/form')
->run(function (MakerTestRunner $runner) {
$this->makeUser($runner, 'userEmail');
@@ -279,54 +270,9 @@ public function getTestDetails()
);
}),
];
-
- yield 'auth_legacy_guard_empty_one_firewall' => [$this->createMakerTest()
- ->addRequiredPackageVersion('symfony/security-bundle', '<5.2')
- ->run(function (MakerTestRunner $runner) {
- $output = $runner->runMaker([
- // authenticator type => empty-auth
- 0,
- // authenticator class name
- 'AppCustomAuthenticator',
- ]);
-
- $this->assertStringContainsString('Success', $output);
-
- $this->assertFileExists($runner->getPath('src/Security/AppCustomAuthenticator.php'));
-
- $securityConfig = $runner->readYaml('config/packages/security.yaml');
- $this->assertEquals(
- 'App\\Security\\AppCustomAuthenticator',
- $securityConfig['security']['firewalls']['main']['guard']['authenticators'][0]
- );
- }),
- ];
-
- yield 'auth_legacy_guard_login_form_user_entity_with_encoder' => [$this->createMakerTest()
- ->addRequiredPackageVersion('symfony/security-bundle', '<5.2')
- ->addExtraDependencies('doctrine', 'twig', 'symfony/form')
- ->run(function (MakerTestRunner $runner) {
- $this->makeUser($runner, 'userEmail');
-
- $output = $runner->runMaker([
- // authenticator type => login-form
- 1,
- // class name
- 'AppCustomAuthenticator',
- // controller name
- 'SecurityController',
- // field name
- 'userEmail',
- 'no', // log out
- ]);
-
- $this->assertStringContainsString('Success', $output);
- $this->runLoginTest($runner, 'userEmail');
- }),
- ];
}
- private function runLoginTest(MakerTestRunner $runner, string $userIdentifier, bool $isEntity = true, string $userClass = 'App\\Entity\\User', bool $testLogin = false)
+ private function runLoginTest(MakerTestRunner $runner, string $userIdentifier, bool $isEntity = true, string $userClass = 'App\\Entity\\User', bool $testLogin = false): void
{
$runner->renderTemplateFile(
'make-auth/LoginFlowTest.php.twig',
@@ -348,13 +294,6 @@ private function runLoginTest(MakerTestRunner $runner, string $userIdentifier, b
return $config;
}
- // legacy check for 5.2 and lower "encoders"
- if (isset($config['security']['password_hashers'])) {
- $config['security']['password_hashers'] = [PasswordAuthenticatedUserInterface::class => 'plaintext'];
- } else {
- $config['security']['encoders'] = [UserInterface::class => 'plaintext'];
- }
-
return $config;
});
@@ -364,13 +303,13 @@ private function runLoginTest(MakerTestRunner $runner, string $userIdentifier, b
$runner->runTests();
}
- private function makeUser(MakerTestRunner $runner, string $userIdentifier, bool $isEntity = true, bool $checkPassword = true)
+ private function makeUser(MakerTestRunner $runner, string $userIdentifier, bool $isEntity = true): void
{
$runner->runConsole('make:user', [
'User', // class name
$isEntity ? 'y' : 'n', // entity
$userIdentifier, // identifier
- $checkPassword ? 'y' : 'n', // password
+ 'y', // password
]);
if (!$isEntity) {
diff --git a/tests/Security/InteractiveSecurityHelperTest.php b/tests/Security/InteractiveSecurityHelperTest.php
index dabb0f198..b230f9171 100644
--- a/tests/Security/InteractiveSecurityHelperTest.php
+++ b/tests/Security/InteractiveSecurityHelperTest.php
@@ -75,60 +75,6 @@ public function getFirewallNameTests()
];
}
- public function testGuessEntryPointWithNonExistingFirewallThrowsException()
- {
- $this->expectException(\Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException::class);
-
- /** @var SymfonyStyle|\PHPUnit_Framework_MockObject_MockObject $io */
- $io = $this->createMock(SymfonyStyle::class);
-
- $helper = new InteractiveSecurityHelper();
- $helper->guessEntryPoint($io, [], '', 'foo');
- }
-
- /**
- * @dataProvider getEntryPointTests
- */
- public function testGuestEntryPoint(array $securityData, string $firewallName, bool $multipleAuthenticators = false)
- {
- /** @var SymfonyStyle|\PHPUnit_Framework_MockObject_MockObject $io */
- $io = $this->createMock(SymfonyStyle::class);
- $io->expects($this->exactly(false === $multipleAuthenticators ? 0 : 1))
- ->method('choice');
-
- $helper = new InteractiveSecurityHelper();
- $helper->guessEntryPoint($io, $securityData, 'App\\Security\\NewAuthenticator', $firewallName);
- }
-
- public function getEntryPointTests()
- {
- yield 'no_guard' => [
- ['security' => ['firewalls' => ['main' => []]]],
- 'main',
- ];
-
- yield 'no_authenticators_key' => [
- ['security' => ['firewalls' => ['main' => ['guard' => []]]]],
- 'main',
- ];
-
- yield 'no_authenticator' => [
- ['security' => ['firewalls' => ['main' => ['guard' => ['authenticators' => []]]]]],
- 'main',
- ];
-
- yield 'one_authenticator' => [
- ['security' => ['firewalls' => ['main' => ['guard' => ['authenticators' => ['App\\Security\\Authenticator']]]]]],
- 'main',
- true,
- ];
-
- yield 'one_authenticator_entry_point' => [
- ['security' => ['firewalls' => ['main' => ['guard' => ['entry_point' => 'App\\Security\\Authenticator', 'authenticators' => ['App\\Security\\Authenticator']]]]]],
- 'main',
- ];
- }
-
/**
* @dataProvider getUserClassTests
*/
diff --git a/tests/Security/SecurityConfigUpdaterTest.php b/tests/Security/SecurityConfigUpdaterTest.php
index 03d413630..34911f98d 100644
--- a/tests/Security/SecurityConfigUpdaterTest.php
+++ b/tests/Security/SecurityConfigUpdaterTest.php
@@ -16,8 +16,6 @@
use Symfony\Bundle\MakerBundle\Security\SecurityConfigUpdater;
use Symfony\Bundle\MakerBundle\Security\UserClassConfiguration;
use Symfony\Component\HttpKernel\Log\Logger;
-use Symfony\Component\PasswordHasher\Hasher\NativePasswordHasher;
-use Symfony\Component\Security\Core\Encoder\NativePasswordEncoder;
class SecurityConfigUpdaterTest extends TestCase
{
@@ -37,7 +35,7 @@ class SecurityConfigUpdaterTest extends TestCase
/**
* @dataProvider getUserClassTests
*/
- public function testUpdateForUserClass(UserClassConfiguration $userConfig, string $expectedSourceFilename, string $startingSourceFilename = 'simple_security.yaml')
+ public function testUpdateForUserClass(UserClassConfiguration $userConfig, string $expectedSourceFilename, string $startingSourceFilename = 'simple_security.yaml'): void
{
$this->createLogger();
@@ -49,16 +47,14 @@ public function testUpdateForUserClass(UserClassConfiguration $userConfig, strin
$updater = new SecurityConfigUpdater($this->ysmLogger);
$source = file_get_contents(__DIR__.'/yaml_fixtures/source/'.$startingSourceFilename);
$actualSource = $updater->updateForUserClass($source, $userConfig, $userClass);
- $symfonyVersion = class_exists(NativePasswordHasher::class) ? '5.3' : 'legacy';
- $expectedSource = file_get_contents(__DIR__.'/yaml_fixtures/expected_user_class/'.$symfonyVersion.'/'.$expectedSourceFilename);
+ $expectedSource = file_get_contents(__DIR__.'/yaml_fixtures/expected_user_class/5.3/'.$expectedSourceFilename);
- $bcryptOrAuto = ('5.3' === $symfonyVersion || class_exists(NativePasswordEncoder::class)) ? 'auto' : 'bcrypt';
- $expectedSource = str_replace('{BCRYPT_OR_AUTO}', $bcryptOrAuto, $expectedSource);
+ $expectedSource = str_replace('{BCRYPT_OR_AUTO}', 'auto', $expectedSource);
$this->assertSame($expectedSource, $actualSource);
}
- public function getUserClassTests()
+ public function getUserClassTests(): \Generator
{
yield 'entity_email_password' => [
new UserClassConfiguration(true, 'email', true),
@@ -101,32 +97,32 @@ public function getUserClassTests()
yield 'security_52_empty_security' => [
new UserClassConfiguration(true, 'email', true),
'security_52_entity_email_with_password.yaml',
- 'security_52_empty_security.yaml',
+ 'empty_security.yaml',
];
yield 'security_52_with_firewalls_and_logout' => [
new UserClassConfiguration(true, 'email', true),
'security_52_complex_entity_email_with_password.yaml',
- 'security_52_with_firewalls_and_logout.yaml',
+ 'simple_security_with_firewalls_and_logout.yaml',
];
}
/**
* @dataProvider getAuthenticatorTests
*/
- public function testUpdateForAuthenticator(string $firewallName, $entryPoint, string $expectedSourceFilename, string $startingSourceFilename, bool $logoutSetup, bool $useSecurity51)
+ public function testUpdateForAuthenticator(string $firewallName, $entryPoint, string $expectedSourceFilename, string $startingSourceFilename, bool $logoutSetup): void
{
$this->createLogger();
$updater = new SecurityConfigUpdater($this->ysmLogger);
$source = file_get_contents(__DIR__.'/yaml_fixtures/source/'.$startingSourceFilename);
- $actualSource = $updater->updateForAuthenticator($source, $firewallName, $entryPoint, 'App\\Security\\AppCustomAuthenticator', $logoutSetup, $useSecurity51);
+ $actualSource = $updater->updateForAuthenticator($source, $firewallName, $entryPoint, 'App\\Security\\AppCustomAuthenticator', $logoutSetup);
$expectedSource = file_get_contents(__DIR__.'/yaml_fixtures/expected_authenticator/'.$expectedSourceFilename);
$this->assertSame($expectedSource, $actualSource);
}
- public function getAuthenticatorTests()
+ public function getAuthenticatorTests(): \Generator
{
yield 'empty_source' => [
'main',
@@ -134,7 +130,6 @@ public function getAuthenticatorTests()
'empty_source.yaml',
'empty_security.yaml',
false,
- false,
];
yield 'simple_security' => [
@@ -143,7 +138,6 @@ public function getAuthenticatorTests()
'simple_security_source.yaml',
'simple_security.yaml',
false,
- false,
];
yield 'simple_security_with_firewalls' => [
@@ -152,7 +146,6 @@ public function getAuthenticatorTests()
'simple_security_with_firewalls.yaml',
'simple_security_with_firewalls.yaml',
false,
- false,
];
yield 'simple_security_with_firewalls_and_authenticator' => [
@@ -161,7 +154,6 @@ public function getAuthenticatorTests()
'simple_security_with_firewalls_and_authenticator.yaml',
'simple_security_with_firewalls_and_authenticator.yaml',
false,
- false,
];
yield 'simple_security_with_firewalls_and_logout' => [
@@ -170,34 +162,14 @@ public function getAuthenticatorTests()
'simple_security_with_firewalls_and_logout.yaml',
'simple_security_with_firewalls_and_logout.yaml',
true,
- false,
- ];
-
- yield 'security_52_empty_source' => [
- 'main',
- null,
- 'security_52_empty_source.yaml',
- 'security_52_empty_security.yaml',
- false,
- true,
- ];
-
- yield 'security_52_simple_security_with_firewalls_and_logout' => [
- 'main',
- 'App\\Security\\AppCustomAuthenticator',
- 'security_52_with_firewalls_and_logout.yaml',
- 'security_52_with_firewalls_and_logout.yaml',
- true,
- true,
];
yield 'security_52_with_multiple_authenticators' => [
'main',
'App\\Security\\AppCustomAuthenticator',
- 'security_52_with_multiple_authenticators.yaml',
- 'security_52_with_multiple_authenticators.yaml',
+ 'multiple_authenticators.yaml',
+ 'multiple_authenticators.yaml',
false,
- true,
];
}
diff --git a/tests/Security/yaml_fixtures/expected_authenticator/empty_source.yaml b/tests/Security/yaml_fixtures/expected_authenticator/empty_source.yaml
index 43063acf5..82d0bdf16 100644
--- a/tests/Security/yaml_fixtures/expected_authenticator/empty_source.yaml
+++ b/tests/Security/yaml_fixtures/expected_authenticator/empty_source.yaml
@@ -1,6 +1,7 @@
security:
+ enable_authenticator_manager: true
+
firewalls:
main:
- anonymous: lazy
- guard:
- authenticators: [App\Security\AppCustomAuthenticator]
+ lazy: true
+ custom_authenticator: App\Security\AppCustomAuthenticator
diff --git a/tests/Security/yaml_fixtures/expected_authenticator/security_52_with_multiple_authenticators.yaml b/tests/Security/yaml_fixtures/expected_authenticator/multiple_authenticators.yaml
similarity index 100%
rename from tests/Security/yaml_fixtures/expected_authenticator/security_52_with_multiple_authenticators.yaml
rename to tests/Security/yaml_fixtures/expected_authenticator/multiple_authenticators.yaml
diff --git a/tests/Security/yaml_fixtures/expected_authenticator/security_52_empty_source.yaml b/tests/Security/yaml_fixtures/expected_authenticator/security_52_empty_source.yaml
deleted file mode 100644
index 82d0bdf16..000000000
--- a/tests/Security/yaml_fixtures/expected_authenticator/security_52_empty_source.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-security:
- enable_authenticator_manager: true
-
- firewalls:
- main:
- lazy: true
- custom_authenticator: App\Security\AppCustomAuthenticator
diff --git a/tests/Security/yaml_fixtures/expected_authenticator/security_52_with_firewalls_and_logout.yaml b/tests/Security/yaml_fixtures/expected_authenticator/security_52_with_firewalls_and_logout.yaml
deleted file mode 100644
index bb191e875..000000000
--- a/tests/Security/yaml_fixtures/expected_authenticator/security_52_with_firewalls_and_logout.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-security:
- enable_authenticator_manager: true
- # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
- providers:
- in_memory: { memory: ~ }
-
- firewalls:
- dev:
- pattern: ^/(_(profiler|wdt)|css|images|js)/
- security: false
- main:
- lazy: true
- custom_authenticator: App\Security\AppCustomAuthenticator
-
- # the entry_point start() method determines what happens when an anonymous user accesses a protected page
- entry_point: App\Security\AppCustomAuthenticator
- logout:
- path: app_logout
- # where to redirect after logout
- # target: app_any_route
diff --git a/tests/Security/yaml_fixtures/expected_authenticator/simple_security_source.yaml b/tests/Security/yaml_fixtures/expected_authenticator/simple_security_source.yaml
index 83cce0bc7..4454b289f 100644
--- a/tests/Security/yaml_fixtures/expected_authenticator/simple_security_source.yaml
+++ b/tests/Security/yaml_fixtures/expected_authenticator/simple_security_source.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
in_memory: { memory: ~ }
@@ -6,7 +8,5 @@ security:
firewalls:
dev: ~
main:
- anonymous: lazy
- guard:
- authenticators:
- - App\Security\AppCustomAuthenticator
+ lazy: true
+ custom_authenticator: App\Security\AppCustomAuthenticator
diff --git a/tests/Security/yaml_fixtures/expected_authenticator/simple_security_with_firewalls.yaml b/tests/Security/yaml_fixtures/expected_authenticator/simple_security_with_firewalls.yaml
index 183cbb744..b37c4a49e 100644
--- a/tests/Security/yaml_fixtures/expected_authenticator/simple_security_with_firewalls.yaml
+++ b/tests/Security/yaml_fixtures/expected_authenticator/simple_security_with_firewalls.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
in_memory: { memory: ~ }
@@ -8,7 +10,5 @@ security:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
- anonymous: lazy
- guard:
- authenticators:
- - App\Security\AppCustomAuthenticator
+ lazy: true
+ custom_authenticator: App\Security\AppCustomAuthenticator
diff --git a/tests/Security/yaml_fixtures/expected_authenticator/simple_security_with_firewalls_and_authenticator.yaml b/tests/Security/yaml_fixtures/expected_authenticator/simple_security_with_firewalls_and_authenticator.yaml
index a3b3d7e26..fc7fcdc17 100644
--- a/tests/Security/yaml_fixtures/expected_authenticator/simple_security_with_firewalls_and_authenticator.yaml
+++ b/tests/Security/yaml_fixtures/expected_authenticator/simple_security_with_firewalls_and_authenticator.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
in_memory: { memory: ~ }
@@ -8,11 +10,10 @@ security:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
- anonymous: lazy
- guard:
- authenticators:
- - App\Security\Authenticator
- - App\Security\AppCustomAuthenticator
- entry_point: App\Security\AppCustomAuthenticator
+ lazy: true
+ custom_authenticator: App\Security\AppCustomAuthenticator
+
+ # the entry_point start() method determines what happens when an anonymous user accesses a protected page
+ entry_point: App\Security\AppCustomAuthenticator
foo:
- anonymous: lazy
+ lazy: true
diff --git a/tests/Security/yaml_fixtures/expected_authenticator/simple_security_with_firewalls_and_logout.yaml b/tests/Security/yaml_fixtures/expected_authenticator/simple_security_with_firewalls_and_logout.yaml
index 0a63d44cf..c144efafd 100644
--- a/tests/Security/yaml_fixtures/expected_authenticator/simple_security_with_firewalls_and_logout.yaml
+++ b/tests/Security/yaml_fixtures/expected_authenticator/simple_security_with_firewalls_and_logout.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
in_memory: { memory: ~ }
@@ -8,10 +10,11 @@ security:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
- anonymous: lazy
- guard:
- authenticators:
- - App\Security\AppCustomAuthenticator
+ lazy: true
+ custom_authenticator: App\Security\AppCustomAuthenticator
+
+ # the entry_point start() method determines what happens when an anonymous user accesses a protected page
+ entry_point: App\Security\AppCustomAuthenticator
logout:
path: app_logout
# where to redirect after logout
diff --git a/tests/Security/yaml_fixtures/expected_user_class/5.3/empty_source_model_email_with_password.yaml b/tests/Security/yaml_fixtures/expected_user_class/5.3/empty_source_model_email_with_password.yaml
index 732eea848..c30fa6a8e 100644
--- a/tests/Security/yaml_fixtures/expected_user_class/5.3/empty_source_model_email_with_password.yaml
+++ b/tests/Security/yaml_fixtures/expected_user_class/5.3/empty_source_model_email_with_password.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
password_hashers:
App\Security\User:
algorithm: {BCRYPT_OR_AUTO}
diff --git a/tests/Security/yaml_fixtures/expected_user_class/5.3/entity_email_with_password.yaml b/tests/Security/yaml_fixtures/expected_user_class/5.3/entity_email_with_password.yaml
index 47866590a..a75a05e5a 100644
--- a/tests/Security/yaml_fixtures/expected_user_class/5.3/entity_email_with_password.yaml
+++ b/tests/Security/yaml_fixtures/expected_user_class/5.3/entity_email_with_password.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
password_hashers:
App\Entity\User:
algorithm: {BCRYPT_OR_AUTO}
diff --git a/tests/Security/yaml_fixtures/expected_user_class/5.3/entity_username_no_password.yaml b/tests/Security/yaml_fixtures/expected_user_class/5.3/entity_username_no_password.yaml
index 5cef6b8b0..87c65dfd6 100644
--- a/tests/Security/yaml_fixtures/expected_user_class/5.3/entity_username_no_password.yaml
+++ b/tests/Security/yaml_fixtures/expected_user_class/5.3/entity_username_no_password.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
# used to reload user from session & other features (e.g. switch_user)
diff --git a/tests/Security/yaml_fixtures/expected_user_class/5.3/model_email_password_existing_providers.yaml b/tests/Security/yaml_fixtures/expected_user_class/5.3/model_email_password_existing_providers.yaml
index db129ff31..66dd79d8e 100644
--- a/tests/Security/yaml_fixtures/expected_user_class/5.3/model_email_password_existing_providers.yaml
+++ b/tests/Security/yaml_fixtures/expected_user_class/5.3/model_email_password_existing_providers.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
password_hashers:
App\Security\User:
algorithm: {BCRYPT_OR_AUTO}
diff --git a/tests/Security/yaml_fixtures/expected_user_class/5.3/model_email_with_password.yaml b/tests/Security/yaml_fixtures/expected_user_class/5.3/model_email_with_password.yaml
index 93623141e..3dfff54d0 100644
--- a/tests/Security/yaml_fixtures/expected_user_class/5.3/model_email_with_password.yaml
+++ b/tests/Security/yaml_fixtures/expected_user_class/5.3/model_email_with_password.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
password_hashers:
App\Security\User:
algorithm: {BCRYPT_OR_AUTO}
diff --git a/tests/Security/yaml_fixtures/expected_user_class/5.3/model_username_no_password.yaml b/tests/Security/yaml_fixtures/expected_user_class/5.3/model_username_no_password.yaml
index f66911320..efa3260c0 100644
--- a/tests/Security/yaml_fixtures/expected_user_class/5.3/model_username_no_password.yaml
+++ b/tests/Security/yaml_fixtures/expected_user_class/5.3/model_username_no_password.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
# used to reload user from session & other features (e.g. switch_user)
diff --git a/tests/Security/yaml_fixtures/expected_user_class/5.3/security_52_complex_entity_email_with_password.yaml b/tests/Security/yaml_fixtures/expected_user_class/5.3/security_52_complex_entity_email_with_password.yaml
index 7b5119f4a..ceeabcfbc 100644
--- a/tests/Security/yaml_fixtures/expected_user_class/5.3/security_52_complex_entity_email_with_password.yaml
+++ b/tests/Security/yaml_fixtures/expected_user_class/5.3/security_52_complex_entity_email_with_password.yaml
@@ -1,5 +1,6 @@
security:
enable_authenticator_manager: true
+
password_hashers:
App\Entity\User:
algorithm: {BCRYPT_OR_AUTO}
diff --git a/tests/Security/yaml_fixtures/expected_user_class/5.3/simple_security_with_single_memory_provider_configured.yaml b/tests/Security/yaml_fixtures/expected_user_class/5.3/simple_security_with_single_memory_provider_configured.yaml
index 7ca690651..e1970ecbf 100644
--- a/tests/Security/yaml_fixtures/expected_user_class/5.3/simple_security_with_single_memory_provider_configured.yaml
+++ b/tests/Security/yaml_fixtures/expected_user_class/5.3/simple_security_with_single_memory_provider_configured.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
password_hashers:
App\Entity\User:
algorithm: {BCRYPT_OR_AUTO}
@@ -14,5 +16,5 @@ security:
firewalls:
dev: ~
main:
- anonymous: lazy
+ lazy: true
provider: app_user_provider
diff --git a/tests/Security/yaml_fixtures/expected_user_class/legacy/empty_source_model_email_with_password.yaml b/tests/Security/yaml_fixtures/expected_user_class/legacy/empty_source_model_email_with_password.yaml
deleted file mode 100644
index 35cd17454..000000000
--- a/tests/Security/yaml_fixtures/expected_user_class/legacy/empty_source_model_email_with_password.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-security:
- encoders:
- App\Security\User:
- algorithm: {BCRYPT_OR_AUTO}
-
- providers:
- # used to reload user from session & other features (e.g. switch_user)
- app_user_provider:
- id: App\Security\UserProvider
diff --git a/tests/Security/yaml_fixtures/expected_user_class/legacy/entity_email_with_password.yaml b/tests/Security/yaml_fixtures/expected_user_class/legacy/entity_email_with_password.yaml
deleted file mode 100644
index ed80168d1..000000000
--- a/tests/Security/yaml_fixtures/expected_user_class/legacy/entity_email_with_password.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-security:
- encoders:
- App\Entity\User:
- algorithm: {BCRYPT_OR_AUTO}
-
- # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
- providers:
- # used to reload user from session & other features (e.g. switch_user)
- app_user_provider:
- entity:
- class: App\Entity\User
- property: email
-
- firewalls:
- dev: ~
- main: ~
diff --git a/tests/Security/yaml_fixtures/expected_user_class/legacy/entity_username_no_password.yaml b/tests/Security/yaml_fixtures/expected_user_class/legacy/entity_username_no_password.yaml
deleted file mode 100644
index 5cef6b8b0..000000000
--- a/tests/Security/yaml_fixtures/expected_user_class/legacy/entity_username_no_password.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-security:
- # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
- providers:
- # used to reload user from session & other features (e.g. switch_user)
- app_user_provider:
- entity:
- class: App\Entity\User
- property: username
-
- firewalls:
- dev: ~
- main: ~
diff --git a/tests/Security/yaml_fixtures/expected_user_class/legacy/model_email_password_existing_providers.yaml b/tests/Security/yaml_fixtures/expected_user_class/legacy/model_email_password_existing_providers.yaml
deleted file mode 100644
index ad7f88e35..000000000
--- a/tests/Security/yaml_fixtures/expected_user_class/legacy/model_email_password_existing_providers.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-security:
- encoders:
- App\Security\User:
- algorithm: {BCRYPT_OR_AUTO}
-
- # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
- providers:
- in_memory: { memory: ~ }
- other_provider: { foo: true }
- # used to reload user from session & other features (e.g. switch_user)
- app_user_provider:
- id: App\Security\UserProvider
-
- firewalls:
- dev: ~
- main: ~
diff --git a/tests/Security/yaml_fixtures/expected_user_class/legacy/model_email_with_password.yaml b/tests/Security/yaml_fixtures/expected_user_class/legacy/model_email_with_password.yaml
deleted file mode 100644
index d2146ec2f..000000000
--- a/tests/Security/yaml_fixtures/expected_user_class/legacy/model_email_with_password.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-security:
- encoders:
- App\Security\User:
- algorithm: {BCRYPT_OR_AUTO}
-
- # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
- providers:
- # used to reload user from session & other features (e.g. switch_user)
- app_user_provider:
- id: App\Security\UserProvider
-
- firewalls:
- dev: ~
- main: ~
diff --git a/tests/Security/yaml_fixtures/expected_user_class/legacy/model_username_no_password.yaml b/tests/Security/yaml_fixtures/expected_user_class/legacy/model_username_no_password.yaml
deleted file mode 100644
index f66911320..000000000
--- a/tests/Security/yaml_fixtures/expected_user_class/legacy/model_username_no_password.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-security:
- # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
- providers:
- # used to reload user from session & other features (e.g. switch_user)
- app_user_provider:
- id: App\Security\UserProvider
-
- firewalls:
- dev: ~
- main: ~
diff --git a/tests/Security/yaml_fixtures/expected_user_class/legacy/security_52_complex_entity_email_with_password.yaml b/tests/Security/yaml_fixtures/expected_user_class/legacy/security_52_complex_entity_email_with_password.yaml
deleted file mode 100644
index b43761262..000000000
--- a/tests/Security/yaml_fixtures/expected_user_class/legacy/security_52_complex_entity_email_with_password.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-security:
- enable_authenticator_manager: true
- encoders:
- App\Entity\User:
- algorithm: {BCRYPT_OR_AUTO}
-
- # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
- providers:
- # used to reload user from session & other features (e.g. switch_user)
- app_user_provider:
- entity:
- class: App\Entity\User
- property: email
-
- firewalls:
- dev:
- pattern: ^/(_(profiler|wdt)|css|images|js)/
- security: false
- main:
- lazy: true
diff --git a/tests/Security/yaml_fixtures/expected_user_class/legacy/security_52_entity_email_with_password.yaml b/tests/Security/yaml_fixtures/expected_user_class/legacy/security_52_entity_email_with_password.yaml
deleted file mode 100644
index 8bf25fc6f..000000000
--- a/tests/Security/yaml_fixtures/expected_user_class/legacy/security_52_entity_email_with_password.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-security:
- enable_authenticator_manager: true
-
- encoders:
- App\Entity\User:
- algorithm: {BCRYPT_OR_AUTO}
-
- providers:
- # used to reload user from session & other features (e.g. switch_user)
- app_user_provider:
- entity:
- class: App\Entity\User
- property: email
diff --git a/tests/Security/yaml_fixtures/expected_user_class/legacy/simple_security_with_single_memory_provider_configured.yaml b/tests/Security/yaml_fixtures/expected_user_class/legacy/simple_security_with_single_memory_provider_configured.yaml
deleted file mode 100644
index 2896481a2..000000000
--- a/tests/Security/yaml_fixtures/expected_user_class/legacy/simple_security_with_single_memory_provider_configured.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-security:
- encoders:
- App\Entity\User:
- algorithm: {BCRYPT_OR_AUTO}
-
- # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
- providers:
- # used to reload user from session & other features (e.g. switch_user)
- app_user_provider:
- entity:
- class: App\Entity\User
- property: email
-
- firewalls:
- dev: ~
- main:
- anonymous: lazy
- provider: app_user_provider
diff --git a/tests/Security/yaml_fixtures/source/empty_security.yaml b/tests/Security/yaml_fixtures/source/empty_security.yaml
index 6dbd9183e..f1e0ffdd4 100644
--- a/tests/Security/yaml_fixtures/source/empty_security.yaml
+++ b/tests/Security/yaml_fixtures/source/empty_security.yaml
@@ -1 +1,2 @@
-security: {}
+security:
+ enable_authenticator_manager: true
diff --git a/tests/Security/yaml_fixtures/source/security_52_with_multiple_authenticators.yaml b/tests/Security/yaml_fixtures/source/multiple_authenticators.yaml
similarity index 100%
rename from tests/Security/yaml_fixtures/source/security_52_with_multiple_authenticators.yaml
rename to tests/Security/yaml_fixtures/source/multiple_authenticators.yaml
diff --git a/tests/Security/yaml_fixtures/source/multiple_providers_security.yaml b/tests/Security/yaml_fixtures/source/multiple_providers_security.yaml
index e8bbb5b07..feb4d59b2 100644
--- a/tests/Security/yaml_fixtures/source/multiple_providers_security.yaml
+++ b/tests/Security/yaml_fixtures/source/multiple_providers_security.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
in_memory: { memory: ~ }
diff --git a/tests/Security/yaml_fixtures/source/security_52_empty_security.yaml b/tests/Security/yaml_fixtures/source/security_52_empty_security.yaml
deleted file mode 100644
index f1e0ffdd4..000000000
--- a/tests/Security/yaml_fixtures/source/security_52_empty_security.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-security:
- enable_authenticator_manager: true
diff --git a/tests/Security/yaml_fixtures/source/security_52_with_firewalls_and_logout.yaml b/tests/Security/yaml_fixtures/source/security_52_with_firewalls_and_logout.yaml
deleted file mode 100644
index 5b6b7af8c..000000000
--- a/tests/Security/yaml_fixtures/source/security_52_with_firewalls_and_logout.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-security:
- enable_authenticator_manager: true
- # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
- providers:
- in_memory: { memory: ~ }
-
- firewalls:
- dev:
- pattern: ^/(_(profiler|wdt)|css|images|js)/
- security: false
- main:
- lazy: true
diff --git a/tests/Security/yaml_fixtures/source/simple_security.yaml b/tests/Security/yaml_fixtures/source/simple_security.yaml
index 61b340dee..0ad604310 100644
--- a/tests/Security/yaml_fixtures/source/simple_security.yaml
+++ b/tests/Security/yaml_fixtures/source/simple_security.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
in_memory: { memory: ~ }
diff --git a/tests/Security/yaml_fixtures/source/simple_security_with_firewalls.yaml b/tests/Security/yaml_fixtures/source/simple_security_with_firewalls.yaml
index 4bf4bf561..b7a84719f 100644
--- a/tests/Security/yaml_fixtures/source/simple_security_with_firewalls.yaml
+++ b/tests/Security/yaml_fixtures/source/simple_security_with_firewalls.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
in_memory: { memory: ~ }
@@ -8,4 +10,4 @@ security:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
- anonymous: lazy
+ lazy: true
diff --git a/tests/Security/yaml_fixtures/source/simple_security_with_firewalls_and_authenticator.yaml b/tests/Security/yaml_fixtures/source/simple_security_with_firewalls_and_authenticator.yaml
index 0518625f5..95cc55505 100644
--- a/tests/Security/yaml_fixtures/source/simple_security_with_firewalls_and_authenticator.yaml
+++ b/tests/Security/yaml_fixtures/source/simple_security_with_firewalls_and_authenticator.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
in_memory: { memory: ~ }
@@ -8,9 +10,6 @@ security:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
- anonymous: lazy
- guard:
- authenticators:
- - App\Security\Authenticator
+ lazy: true
foo:
- anonymous: lazy
+ lazy: true
diff --git a/tests/Security/yaml_fixtures/source/simple_security_with_firewalls_and_logout.yaml b/tests/Security/yaml_fixtures/source/simple_security_with_firewalls_and_logout.yaml
index 4bf4bf561..b7a84719f 100644
--- a/tests/Security/yaml_fixtures/source/simple_security_with_firewalls_and_logout.yaml
+++ b/tests/Security/yaml_fixtures/source/simple_security_with_firewalls_and_logout.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
in_memory: { memory: ~ }
@@ -8,4 +10,4 @@ security:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
- anonymous: lazy
+ lazy: true
diff --git a/tests/Security/yaml_fixtures/source/simple_security_with_single_memory_provider_configured.yaml b/tests/Security/yaml_fixtures/source/simple_security_with_single_memory_provider_configured.yaml
index c0f39446d..80053e101 100644
--- a/tests/Security/yaml_fixtures/source/simple_security_with_single_memory_provider_configured.yaml
+++ b/tests/Security/yaml_fixtures/source/simple_security_with_single_memory_provider_configured.yaml
@@ -1,4 +1,6 @@
security:
+ enable_authenticator_manager: true
+
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
in_memory: { memory: ~ }
@@ -6,5 +8,5 @@ security:
firewalls:
dev: ~
main:
- anonymous: lazy
+ lazy: true
provider: in_memory