EDIT:
Forget it, I've just added the:
- { path: ^/admin/login, roles: PUBLIC_ACCESS }
and now it works.
I have an issue with login page, it gaves me too many redirects. I saw a lot of posts about it, but I can not found out what could be the problem.
Here is my security.yaml
security:
enable_authenticator_manager: true
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
algorithm: 'bcrypt'
providers:
users_in_memory:
memory:
users:
myadmin: {password: '$2y$13$Roa09 ...... swa3dz4y', roles: [ 'ROLE_ADMIN' ]}
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
lazy: true
provider: users_in_memory
form_login:
login_path: app.admin.login
check_path: app.admin.login
logout:
path: app.admin.logout
target: app.main
access_control:
- { path: ^/admin, roles: ROLE_ADMIN }
And the controller:
<?php
namespace App\Controller\Admin;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class SecurityController extends AbstractController
{
/**
*
* @param AuthenticationUtils $authenticationUtils
* @return Response
*
* @Route("/admin/login/", name="app.admin.login")
*/
public function index(AuthenticationUtils $authenticationUtils): Response
{
$error = $authenticationUtils->getLastAuthenticationError();
if (!$error) {
die('success');
}
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('admin/admin.login.html.twig', [
'last_username' => $lastUsername,
'error' => $error,
]);
}
/**
* @return void
*
* @Route("/admin/logout/", name="app.admin.logout")
*/
public function logout()
{
die('logout');
}
}
For some reason, I am getting TOO MANY REDIRECTS
pages and in the dev tools network tab I see, it is always redirects me to the login page. Even, if the app.main.login
starts with a die('stop here');
it does not.
Can somebody enlgihten me, what do I doing wrong?