У меня та же проблема, что и эта. наборы symfony 4, зарегистрированные как анонимные
Пользователи всегда перенаправляются на путь входа в систему.Это мой код security.yaml
security:
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
from_database:
entity:
class: App\Entity\User
property: username
role_hierarchy:
ROLE_ENSEIGNANT_PRIMAIRE: ROLE_USER
ROLE_ENSEIGNANT_SECONDAIRE: ROLE_USER
ROLE_AFFECTATION: ROLE_USER
ROLE_COMPTABILITE: ROLE_USER
ROLE_ETUDE: ROLE_USER
ROLE_SCOLARITE: ROLE_USER
ROLE_RESPONSABLE_CLASSE: ROLE_USER
ROLE_ADMIN: ROLE_USER
ROLE_ENSEIGNANT: [ROLE_ENSEIGNANT_PRIMAIRE, ROLE_ENSEIGNANT_SECONDAIRE]
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ENSEIGNANT, ROLE_AFFECTATION, ROLE_COMPTABILITE, ROLE_ETUDE, ROLE_SCOLARITE, ROLE_RESPONSABLE_CLASSE, ROLE_ALLOWED_TO_SWITCH]
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main_login:
pattern: ^/login$
stateless: true
anonymous: true
main:
pattern: ^/
stateless: true
anonymous: true
form_login:
# Le nom de la route de la page de connexion
check_path: login
# Le nom de la route où se trouve le formulaire de connexion
# Si un utilisateur tente d'acceder à une page protégée sans en avoir les droits
# il sera redirigé sur cette page
login_path: login
# Securisation des formulaires
csrf_token_generator: security.csrf.token_manager
# La page par defaut apres une connexion reussie
default_target_path: check_account
logout:
# La route où se trouve le process de deconnexion
path: logout
# La route sur laquelle doit etre rediriger l'utilisateur apres une deconnexion
target: login
handlers: [app.logout.listener]
# activate different ways to authenticate
# http_basic: true
# https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
# form_login: true
# https://symfony.com/doc/current/security/form_login_setup.html
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
# - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/profile, roles: ROLE_USER }
encoders:
App\Entity\User:
algorithm: bcrypt
cost: 12
А этот, действие входа в систему (в контроллере)
/**
* @Route("/login", name="login")
*/
public function login(Request $request, AuthenticationUtils $helper): Response
{
$current = '';
$params = $request->headers->get('fail');
$referer = $request->headers->get('referer');
return $this->render('Security/login.html.twig', [
// dernier username saisi (si il y en a un)
'last_username' => $helper->getLastUsername(),
// La derniere erreur de connexion (si il y en a une)
'error' => $helper->getLastAuthenticationError(),
'current' => $current,
]);
}
, и я получаю эту ошибку в моем файле журнала
[2019-09-27 14:07:49] request.INFO: Matched route "login". {"route":"login","route_parameters":{"_route":"login","_controller":"App\\Controller\\User\\SecurityController::login"},"request_uri":"http://localhost:8000/login","method":"GET"} []
[2019-09-27 14:07:49] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
[2019-09-27 14:07:49] request.INFO: Matched route "_wdt". {"route":"_wdt","route_parameters":{"_route":"_wdt","_controller":"web_profiler.controller.profiler::toolbarAction","token":"9fa908"},"request_uri":"http://localhost:8000/_wdt/9fa908","method":"GET"} []
Кто-нибудь может сказать мне, что не так?