Skip to content

Commit 4e373c0

Browse files
committed
Fix some tests
1 parent 9e89444 commit 4e373c0

5 files changed

Lines changed: 37 additions & 133 deletions

File tree

manifests/php.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,6 @@ manifest:
367367
- weblog_declaration:
368368
"*": missing_feature (Basic auth not implemented)
369369
laravel11x: v1.8.0
370-
symfony7x: v1.8.0
371370
tests/appsec/test_automated_login_events.py::Test_V3_Login_Events::test_login_sdk_failure_local:
372371
- weblog_declaration:
373372
laravel11x: v1.8.0
@@ -376,7 +375,6 @@ manifest:
376375
- weblog_declaration:
377376
"*": missing_feature (Basic auth not implemented)
378377
laravel11x: v1.8.0
379-
symfony7x: v1.8.0
380378
tests/appsec/test_automated_login_events.py::Test_V3_Login_Events::test_login_sdk_success_local:
381379
- weblog_declaration:
382380
laravel11x: v1.8.0
@@ -385,12 +383,10 @@ manifest:
385383
- weblog_declaration:
386384
"*": missing_feature (Basic auth not implemented)
387385
laravel11x: v1.8.0
388-
symfony7x: v1.8.0
389386
tests/appsec/test_automated_login_events.py::Test_V3_Login_Events::test_login_wrong_password_failure_basic:
390387
- weblog_declaration:
391388
"*": missing_feature (Basic auth not implemented)
392389
laravel11x: v1.8.0
393-
symfony7x: v1.8.0
394390
tests/appsec/test_automated_login_events.py::Test_V3_Login_Events::test_login_wrong_password_failure_local:
395391
- weblog_declaration:
396392
laravel11x: v1.8.0
@@ -399,13 +395,11 @@ manifest:
399395
- weblog_declaration:
400396
"*": missing_feature (Basic auth not implemented)
401397
laravel11x: v1.8.0
402-
symfony7x: v1.8.0
403398
tests/appsec/test_automated_login_events.py::Test_V3_Login_Events_Anon: v1.8.0
404399
tests/appsec/test_automated_login_events.py::Test_V3_Login_Events_Anon::test_login_sdk_failure_basic:
405400
- weblog_declaration:
406401
"*": missing_feature (Basic auth not implemented)
407402
laravel11x: v1.8.0
408-
symfony7x: v1.8.0
409403
tests/appsec/test_automated_login_events.py::Test_V3_Login_Events_Anon::test_login_sdk_failure_local:
410404
- weblog_declaration:
411405
laravel11x: v1.8.0
@@ -414,7 +408,6 @@ manifest:
414408
- weblog_declaration:
415409
"*": missing_feature (Basic auth not implemented)
416410
laravel11x: v1.8.0
417-
symfony7x: v1.8.0
418411
tests/appsec/test_automated_login_events.py::Test_V3_Login_Events_Anon::test_login_sdk_success_local:
419412
- weblog_declaration:
420413
laravel11x: v1.8.0
@@ -423,17 +416,14 @@ manifest:
423416
- weblog_declaration:
424417
"*": missing_feature (Basic auth not implemented)
425418
laravel11x: v1.8.0
426-
symfony7x: v1.8.0
427419
tests/appsec/test_automated_login_events.py::Test_V3_Login_Events_Anon::test_login_wrong_password_failure_basic:
428420
- weblog_declaration:
429421
"*": missing_feature (Basic auth not implemented)
430422
laravel11x: v1.8.0
431-
symfony7x: v1.8.0
432423
tests/appsec/test_automated_login_events.py::Test_V3_Login_Events_Anon::test_login_wrong_user_failure_basic:
433424
- weblog_declaration:
434425
"*": missing_feature (Basic auth not implemented)
435426
laravel11x: v1.8.0
436-
symfony7x: v1.8.0
437427
tests/appsec/test_automated_login_events.py::Test_V3_Login_Events_Blocking: v1.8.0
438428
tests/appsec/test_automated_login_events.py::Test_V3_Login_Events_RC: v1.8.0
439429
tests/appsec/test_automated_payment_events.py:

utils/build/docker/php/weblogs/symfony7x/config/packages/security.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,20 @@ security:
55

66
providers:
77
app_user_provider:
8-
id: App\Security\UserProvider
9-
8+
entity:
9+
class: App\Entity\User
10+
property: username
1011
firewalls:
1112
main:
1213
pattern: ^/
1314
lazy: true
1415
provider: app_user_provider
1516
stateless: false
16-
custom_authenticators:
17-
- App\Security\AppAuthenticator
17+
form_login:
18+
login_path: login
19+
check_path: login
20+
username_parameter: username
21+
password_parameter: password
22+
success_handler: App\Security\LoginSuccessHandler
1823

1924
access_control: []

utils/build/docker/php/weblogs/symfony7x/src/Controller/LoginController.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
namespace App\Controller;
44

55
use App\Entity\User;
6-
use App\Security\AppAuthenticator;
76
use Doctrine\ORM\EntityManagerInterface;
87
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
98
use Symfony\Bundle\SecurityBundle\Security;
109
use Symfony\Component\HttpFoundation\Request;
1110
use Symfony\Component\HttpFoundation\Response;
1211
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
1312
use Symfony\Component\Routing\Attribute\Route;
14-
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
1513

1614
class LoginController extends AbstractController
1715
{
@@ -25,11 +23,9 @@ public function __construct(
2523
) {}
2624

2725
#[Route('/login', name: 'login', methods: ['GET', 'POST'])]
28-
public function login(AuthenticationUtils $authenticationUtils): Response
26+
public function login(): Response
2927
{
30-
// Authentication is handled by AppAuthenticator.
31-
// This method is reached only for GET requests or when the authenticator does not support the request.
32-
return new Response('', 200);
28+
return new Response('', Response::HTTP_OK);
3329
}
3430

3531
#[Route('/signup', name: 'signup', methods: ['POST'])]
@@ -46,7 +42,7 @@ public function signup(Request $request, EntityManagerInterface $entityManager):
4642
// Signup event is tracked automatically by the tracer via Doctrine\ORM\UnitOfWork::executeInserts hook.
4743
$entityManager->flush();
4844

49-
$this->security->login($user, AppAuthenticator::class, 'main');
45+
$this->security->login($user);
5046

5147
return new Response('', 200);
5248
}

utils/build/docker/php/weblogs/symfony7x/src/Security/AppAuthenticator.php

Lines changed: 0 additions & 112 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace App\Security;
4+
5+
use Symfony\Component\HttpFoundation\Request;
6+
use Symfony\Component\HttpFoundation\Response;
7+
use Symfony\Component\HttpKernel\HttpKernelInterface;
8+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
9+
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
10+
11+
class LoginSuccessHandler implements AuthenticationSuccessHandlerInterface
12+
{
13+
public function __construct(
14+
private HttpKernelInterface $httpKernel,
15+
) {}
16+
17+
public function onAuthenticationSuccess(Request $request, TokenInterface $token): Response
18+
{
19+
$subRequest = $request->duplicate();
20+
$subRequest->setMethod('GET');
21+
$subRequest->request->replace([]);
22+
23+
return $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
24+
}
25+
}

0 commit comments

Comments
 (0)