Skip to content

Commit 72784c0

Browse files
Remove compatibility with 6.3
1 parent ce2bfd3 commit 72784c0

16 files changed

+11
-303
lines changed

src/Maker/MakeAuthenticator.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use Symfony\Bundle\MakerBundle\Security\SecurityControllerBuilder;
2525
use Symfony\Bundle\MakerBundle\Str;
2626
use Symfony\Bundle\MakerBundle\Util\ClassSourceManipulator;
27-
use Symfony\Bundle\MakerBundle\Util\FeatureSupportTrait;
2827
use Symfony\Bundle\MakerBundle\Util\UseStatementGenerator;
2928
use Symfony\Bundle\MakerBundle\Util\YamlManipulationFailedException;
3029
use Symfony\Bundle\MakerBundle\Util\YamlSourceManipulator;
@@ -63,7 +62,6 @@
6362
*/
6463
final class MakeAuthenticator extends AbstractMaker
6564
{
66-
use FeatureSupportTrait;
6765
private const AUTH_TYPE_EMPTY_AUTHENTICATOR = 'empty-authenticator';
6866
private const AUTH_TYPE_FORM_LOGIN = 'form-login';
6967

@@ -278,7 +276,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
278276
$input->hasArgument('logout-setup') ? $input->getArgument('logout-setup') : false,
279277
$supportRememberMe,
280278
$alwaysRememberMe,
281-
$this->supportsLogoutRouteLoader() && !file_exists('config/routes/security.yaml'),
279+
!file_exists('config/routes/security.yaml'),
282280
)
283281
);
284282
}
@@ -383,10 +381,6 @@ private function generateFormLoginFiles(string $controllerClass, string $userNam
383381

384382
$this->securityControllerBuilder->addLoginMethod($manipulator);
385383

386-
if ($logoutSetup && !$this->supportsLogoutRouteLoader()) {
387-
$this->securityControllerBuilder->addLogoutMethod($manipulator);
388-
}
389-
390384
$this->generator->dumpFile($controllerPath, $manipulator->getSourceCode());
391385

392386
// create login form template
@@ -404,7 +398,7 @@ private function generateFormLoginFiles(string $controllerClass, string $userNam
404398
);
405399
}
406400

407-
private function generateNextMessage(bool $securityYamlUpdated, string $authenticatorType, string $authenticatorClass, $userClass, bool $logoutSetup, bool $supportRememberMe, bool $alwaysRememberMe, bool $defaultSecurityRoute): array
401+
private function generateNextMessage(bool $securityYamlUpdated, string $authenticatorType, string $authenticatorClass, $userClass, bool $logoutSetup, bool $supportRememberMe, bool $alwaysRememberMe, bool $hasSecurityRouteFile): array
408402
{
409403
$nextTexts = ['Next:'];
410404
$nextTexts[] = '- Customize your new authenticator.';
@@ -433,7 +427,9 @@ private function generateNextMessage(bool $securityYamlUpdated, string $authenti
433427
}
434428

435429
// If the security.logout_route_loader is not loaded from the default flex recipe
436-
$nextTexts[] = '- Be sure to add the "logout" route to <info>config/routes/security.yaml</info> or upgrade the <info>symfony/security-bundle</info> recipe.';
430+
if (!$hasSecurityRouteFile) {
431+
$nextTexts[] = '- Be sure to add the "logout" route to <info>config/routes/security.yaml</info> or upgrade the <info>symfony/security-bundle</info> recipe.';
432+
}
437433

438434
return $nextTexts;
439435
}

src/Maker/Security/MakeFormLogin.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use Symfony\Bundle\MakerBundle\Security\SecurityControllerBuilder;
2626
use Symfony\Bundle\MakerBundle\Str;
2727
use Symfony\Bundle\MakerBundle\Util\ClassSourceManipulator;
28-
use Symfony\Bundle\MakerBundle\Util\FeatureSupportTrait;
2928
use Symfony\Bundle\MakerBundle\Util\UseStatementGenerator;
3029
use Symfony\Bundle\MakerBundle\Util\YamlSourceManipulator;
3130
use Symfony\Bundle\MakerBundle\Validator;
@@ -49,8 +48,6 @@
4948
*/
5049
final class MakeFormLogin extends AbstractMaker
5150
{
52-
use FeatureSupportTrait;
53-
5451
private const SECURITY_CONFIG_PATH = 'config/packages/security.yaml';
5552
private YamlSourceManipulator $ysm;
5653
private string $controllerName;
@@ -136,7 +133,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
136133
$controllerNameDetails = $generator->createClassNameDetails($this->controllerName, 'Controller\\', 'Controller');
137134
$templatePath = strtolower($controllerNameDetails->getRelativeNameWithoutSuffix());
138135

139-
$controllerPath = $generator->generateController(
136+
$generator->generateController(
140137
$controllerNameDetails->getFullName(),
141138
'security/formLogin/LoginController.tpl.php',
142139
[
@@ -146,14 +143,6 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
146143
]
147144
);
148145

149-
if ($this->willLogout && !$this->supportsLogoutRouteLoader()) {
150-
$manipulator = new ClassSourceManipulator($generator->getFileContentsForPendingOperation($controllerPath));
151-
152-
$this->securityControllerBuilder->addLogoutMethod($manipulator);
153-
154-
$generator->dumpFile($controllerPath, $manipulator->getSourceCode());
155-
}
156-
157146
$generator->generateTemplate(
158147
sprintf('%s/login.html.twig', $templatePath),
159148
'security/formLogin/login_form.tpl.php',

src/Util/FeatureSupportTrait.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

tests/Maker/MakeAuthenticatorTest.php

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -269,50 +269,6 @@ public function getTestDetails(): \Generator
269269
$this->assertFileExists($runner->getPath('templates/security/login.html.twig'));
270270
$this->assertFileExists($runner->getPath('src/Security/AppCustomAuthenticator.php'));
271271

272-
$securityConfig = $runner->readYaml('config/packages/security.yaml');
273-
$this->assertEquals(
274-
'app_logout',
275-
$securityConfig['security']['firewalls']['main']['logout']['path']
276-
);
277-
}),
278-
];
279-
280-
yield 'auth_login_form_user_entity_with_logout_route_loader' => [$this->createMakerTest()
281-
->addExtraDependencies('doctrine', 'twig', 'symfony/form')
282-
->run(function (MakerTestRunner $runner) {
283-
$this->makeUser($runner, 'userEmail');
284-
// We pretend that the LogoutRouteLoader is registered
285-
$runner->addToAutoloader('Symfony\\Bundle\\SecurityBundle\\Routing\\', \dirname(__DIR__).'/fixtures/security-bundle/routing/');
286-
$runner->modifyYamlFile('config/services.yaml', function (array $config) {
287-
$config['services']['security.route_loader.logout'] = [
288-
'class' => 'Symfony\Bundle\SecurityBundle\\Routing\\LogoutRouteLoader',
289-
'tags' => ['routing.route_loader'],
290-
];
291-
292-
return $config;
293-
});
294-
$output = $runner->runMaker([
295-
// authenticator type => login-form
296-
1,
297-
// class name
298-
'AppCustomAuthenticator',
299-
// controller name
300-
'SecurityController',
301-
// logout support
302-
'yes',
303-
// remember me support => no
304-
'no',
305-
]);
306-
307-
$this->runLoginTest($runner, 'userEmail', true, 'App\\Entity\\User', true);
308-
309-
$this->assertStringContainsString('Success', $output);
310-
311-
$this->assertFileExists($runner->getPath('src/Controller/SecurityController.php'));
312-
$this->assertFileEquals(\dirname(__DIR__).'/fixtures/make-auth/SecurityController-no-logout.php', $runner->getPath('src/Controller/SecurityController.php'));
313-
$this->assertFileExists($runner->getPath('templates/security/login.html.twig'));
314-
$this->assertFileExists($runner->getPath('src/Security/AppCustomAuthenticator.php'));
315-
316272
$securityConfig = $runner->readYaml('config/packages/security.yaml');
317273
$this->assertEquals(
318274
'/logout',

tests/Maker/Security/MakeFormLoginTest.php

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function getTestDetails(): \Generator
4848
$this->assertSame('app_login', $securityConfig['security']['firewalls']['main']['form_login']['login_path']);
4949
$this->assertSame('app_login', $securityConfig['security']['firewalls']['main']['form_login']['check_path']);
5050
$this->assertTrue($securityConfig['security']['firewalls']['main']['form_login']['enable_csrf']);
51-
$this->assertSame('app_logout', $securityConfig['security']['firewalls']['main']['logout']['path']);
51+
$this->assertSame('/logout', $securityConfig['security']['firewalls']['main']['logout']['path']);
5252

5353
$this->runLoginTest($runner);
5454
}),
@@ -66,7 +66,7 @@ public function getTestDetails(): \Generator
6666
$this->assertStringContainsString('Success', $output);
6767
$fixturePath = \dirname(__DIR__, 2).'/fixtures/security/make-form-login/expected';
6868

69-
$this->assertFileEquals($fixturePath.'/SecurityControllerWithoutLogout.php', $runner->getPath('src/Controller/SecurityController.php'));
69+
$this->assertFileEquals($fixturePath.'/SecurityController.php', $runner->getPath('src/Controller/SecurityController.php'));
7070
$this->assertFileEquals($fixturePath.'/login_no_logout.html.twig', $runner->getPath('templates/security/login.html.twig'));
7171

7272
$securityConfig = $runner->readYaml('config/packages/security.yaml');
@@ -94,30 +94,6 @@ public function getTestDetails(): \Generator
9494

9595
$securityConfig = $runner->readYaml('config/packages/security.yaml');
9696

97-
$this->assertSame('app_login', $securityConfig['security']['firewalls']['main']['form_login']['login_path']);
98-
$this->assertSame('app_login', $securityConfig['security']['firewalls']['main']['form_login']['check_path']);
99-
$this->assertSame('app_logout', $securityConfig['security']['firewalls']['main']['logout']['path']);
100-
}),
101-
];
102-
103-
yield 'generates_form_login_with_logout_with_route_loader' => [$this->createMakerTest()
104-
->run(function (MakerTestRunner $runner) {
105-
// We pretend that the LogoutRouteLoader is registered
106-
$runner->addToAutoloader('Symfony\\Bundle\\SecurityBundle\\Routing\\', \dirname(__DIR__, 2).'/fixtures/security-bundle/routing');
107-
$this->makeUser($runner);
108-
$output = $runner->runMaker([
109-
'SecurityController', // Controller Name
110-
'y', // Generate Logout
111-
]);
112-
113-
$this->assertStringContainsString('Success', $output);
114-
$fixturePath = \dirname(__DIR__, 2).'/fixtures/security/make-form-login/expected';
115-
116-
$this->assertFileEquals($fixturePath.'/SecurityControllerLogoutRouteLoader.php', $runner->getPath('src/Controller/SecurityController.php'));
117-
$this->assertFileEquals($fixturePath.'/login_routeloader_logout.html.twig', $runner->getPath('templates/security/login.html.twig'));
118-
119-
$securityConfig = $runner->readYaml('config/packages/security.yaml');
120-
12197
$this->assertSame('app_login', $securityConfig['security']['firewalls']['main']['form_login']['login_path']);
12298
$this->assertSame('app_login', $securityConfig['security']['firewalls']['main']['form_login']['check_path']);
12399
$this->assertSame('/logout', $securityConfig['security']['firewalls']['main']['logout']['path']);

tests/Security/SecurityConfigUpdaterTest.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,11 @@ public function getUserClassTests(): \Generator
104104
/**
105105
* @dataProvider getAuthenticatorTests
106106
*/
107-
public function testUpdateForAuthenticator(string $firewallName, $entryPoint, string $expectedSourceFilename, string $startingSourceFilename, bool $logoutSetup, bool $supportRememberMe, bool $alwaysRememberMe, bool $useLogoutRouteLoader = false): void
107+
public function testUpdateForAuthenticator(string $firewallName, $entryPoint, string $expectedSourceFilename, string $startingSourceFilename, bool $logoutSetup, bool $supportRememberMe, bool $alwaysRememberMe): void
108108
{
109109
$this->createLogger();
110110

111111
$updater = new SecurityConfigUpdater($this->ysmLogger);
112-
if ($useLogoutRouteLoader) {
113-
$updater->forceSupportLogoutRouteLoader();
114-
}
115112
$source = file_get_contents(__DIR__.'/yaml_fixtures/source/'.$startingSourceFilename);
116113
$actualSource = $updater->updateForAuthenticator($source, $firewallName, $entryPoint, 'App\\Security\\AppCustomAuthenticator', $logoutSetup, $supportRememberMe, $alwaysRememberMe);
117114
$expectedSource = file_get_contents(__DIR__.'/yaml_fixtures/expected_authenticator/'.$expectedSourceFilename);
@@ -200,17 +197,6 @@ public function getAuthenticatorTests(): \Generator
200197
true,
201198
true,
202199
];
203-
204-
yield 'simple_security_with_firewalls_and_logout_via_loader' => [
205-
'main',
206-
'App\\Security\\AppCustomAuthenticator',
207-
'simple_security_with_firewalls_and_logout_via_loader.yaml',
208-
'simple_security_with_firewalls_and_logout.yaml',
209-
true,
210-
false,
211-
false,
212-
true,
213-
];
214200
}
215201

216202
public function testUpdateForFormLogin(): void

tests/Security/yaml_fixtures/expected_authenticator/simple_security_with_firewalls_and_logout.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ security:
1616
# the entry_point start() method determines what happens when an anonymous user accesses a protected page
1717
entry_point: App\Security\AppCustomAuthenticator
1818
logout:
19-
path: app_logout
19+
path: /logout
2020
# where to redirect after logout
2121
# target: app_any_route

tests/Security/yaml_fixtures/expected_authenticator/simple_security_with_firewalls_and_logout_via_loader.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

tests/Security/yaml_fixtures/expected_logout/logout.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ security:
1212
main:
1313
lazy: true
1414
logout:
15-
path: app_logout
15+
path: /logout
1616
# where to redirect after logout
1717
# target: app_any_route

tests/fixtures/make-auth/SecurityController-no-logout.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/fixtures/security-bundle/routing/LogoutRouteLoader.php

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/fixtures/security/make-form-login/expected/LoginController.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,4 @@ public function login(AuthenticationUtils $authenticationUtils): Response
2323
'error' => $error,
2424
]);
2525
}
26-
27-
#[Route(path: '/logout', name: 'app_logout')]
28-
public function logout(): void
29-
{
30-
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
31-
}
3226
}

tests/fixtures/security/make-form-login/expected/SecurityController.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,4 @@ public function login(AuthenticationUtils $authenticationUtils): Response
2323
'error' => $error,
2424
]);
2525
}
26-
27-
#[Route(path: '/logout', name: 'app_logout')]
28-
public function logout(): void
29-
{
30-
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
31-
}
3226
}

tests/fixtures/security/make-form-login/expected/SecurityControllerLogoutRouteLoader.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)