Bonjour les ainés en Particulier l'administrateur Grafikart
En me connectant sur ma page administration de easyadmin lorsque je clique sur un lien ou sur boutton d'action je suis rediriger vers la page de connexion où on e demande de reconnecter à nouveau
voici le contenue mes fichiers:
secuity.yaml
security:
'nenable_authenticator_manager: true

https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
password_hashers:
    Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
    app_user_provider:
        entity:
            class: App\Entity\Security\Admin\User
            property: email
firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    main:
        lazy: true
        provider: app_user_provider
        form_login:
             # "app_login" is the name of the route created previously
            login_path: app_login
            check_path: app_login
            default_target_path: admin
            always_use_default_target_path: true
            enable_csrf: true
        custom_authenticator: App\Security\AdminAuthenticator
        entry_point: App\Security\AdminAuthenticator
        logout:
            path: app_logout
            # where to redirect after logout
            # target: app_any_route

        # activate different ways to authenticate
        # https://symfony.com/doc/current/security.html#the-firewall

        # https://symfony.com/doc/current/security/impersonating_user.html
        # switch_user: true

# 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: ^/admin, roles: ROLE_ADMIN }
      - { path: ^/login, roles: PUBLIC_ACCESS }

    # - { path: ^/profile, roles: ROLE_USER }

when@test:
security:
password_hashers:

By default, password hashers are resource intensive and take time. This is
        # important to generate secure password hashes. In tests however, secure hashes
        # are not important, waste resources and increase test times. The following
        # reduces the work factor to the lowest possible values.
        Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
            algorithm: auto
            cost: 4 # Lowest possible value for bcrypt
            time_cost: 3 # Lowest possible value for argon
            memory_cost: 10 # Lowest possible value for argon'

AdminAutentificator.php
'<?php

namespace App\Security;

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 Symfony\Component\Security\Http\Util\TargetPathTrait;

class AdminAuthenticator extends AbstractLoginFormAuthenticator
{
use TargetPathTrait;

public const LOGIN_ROUTE = 'app_login';

private UrlGeneratorInterface $urlGenerator;

public function __construct(UrlGeneratorInterface $urlGenerator)
{
    $this->urlGenerator = $urlGenerator;
}

public function authenticate(Request $request): Passport
{
    $email = $request->request->get('email', '');

    $request->getSession()->set(Security::LAST_USERNAME, $email);

    return new Passport(
        new UserBadge($email),
        new PasswordCredentials($request->request->get('password', '')),
        [
            new CsrfTokenBadge('authenticate', $request->request->get('_csrf_token')),
        ]
    );
}

public function supports(Request $request): bool
{
    return $request->isMethod('POST') && $this->getLoginUrl($request) === $request->getRequestUri();
}

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('admin'));
   // throw new \Exception('TODO: provide a valid redirect inside '.__FILE__);
}

protected function getLoginUrl(Request $request): string
{
    return $this->urlGenerator->generate(self::LOGIN_ROUTE);
}

}'
ConnexionController.php
'
<?php

namespace App\Controller;

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 ConnexionController extends AbstractController
{
/**

  • @Route("/login", name="app_login")
    */
    public function login(AuthenticationUtils $authenticationUtils): Response
    {
    // if ($this->getUser()) {
    // return $this->redirectToRoute('admin');

    // }
    
    // get the login error if there is one
    $error = $authenticationUtils->getLastAuthenticationError();
    // last username entered by the user
    $lastUsername = $authenticationUtils->getLastUsername();
    
    return $this->render('@EasyAdmin/page/login.html.twig', [
        // parameters usually defined in Symfony login forms
        'error' => $error,
        'last_username' => $lastUsername,
        // the title visible above the login form (define this option only if you are
        // rendering the login template in a regular Symfony controller; when rendering
        // it from an EasyAdmin Dashboard this is automatically set as the Dashboard title)
        'page_title' => 'Connexion administration',
    
        // the string used to generate the CSRF token. If you don't define
        // this parameter, the login form won't include a CSRF token
        'csrf_token_intention' => 'authenticate',
    
        // the URL users are redirected to after the login (default: '/admin')
        'target_path' => $this->generateUrl('admin'),
    
        // the label displayed for the username form field (the |trans filter is applied to it)
        'username_label' => 'Email',
    
        // the label displayed for the password form field (the |trans filter is applied to it)
        'password_label' => 'Password',
    
        // the label displayed for the Sign In form button (the |trans filter is applied to it)
        'sign_in_label' => 'Connexion',
    
        // the 'name' HTML attribute of the <input> used for the username field (default: '_username')
        'username_parameter' => 'email',
    
        // the 'name' HTML attribute of the <input> used for the password field (default: '_password')
        'password_parameter' => 'password',
    
        // whether to enable or not the "remember me" checkbox (default: false)
        'remember_me_enabled' => true,
    
        // remember me name form field (default: '_remember_me')
        'remember_me_parameter' => '_remember_me',
    
        // whether to check by default the "remember me" checkbox (default: false)
        'remember_me_checked' => true,
    
        // the label displayed for the remember me checkbox (the |trans filter is applied to it)
        'remember_me_label' => 'se souvenir de moi',
    ]);

    }

    /**

  • @Route("/logout", name="app_logout")
    */
    public function logout(): void
    {
    throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
    }
    }

'
AdministrationController.php pour mon Dashboard
'
<?php

namespace App\Controller\Admin;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Config\UserMenu;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use Symfony\Component\Security\Core\User\UserInterface;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;

class AdministrationController extends AbstractDashboardController
{
/**

  • @Route("/admin", name="admin")
    */
    public function index(): Response
    {
    return $this->render('@EasyAdmin/layout.html.twig') ;
    }

    public function configureDashboard(): Dashboard
    {
    return Dashboard::new()
    ->setTitle('Academie');
    }

    public function configureMenuItems(): iterable
    {
    if ($this->getUser()) {
    yield MenuItem::linkToDashboard('Dashboard', 'fa fa-home');
    }

    }
    }

'
voici une partie de mon fichier dev.log
'[2023-10-05T17:52:37.090228+01:00] request.INFO: Matched route "app_login". {"route":"app_login","route_parameters":{"_route":"app_login","_controller":"App\Controller\ConnexionController::login"},"request_uri":"http://127.0.0.1:8000/login","method":"GET"} []
[2023-10-05T17:52:37.097051+01:00] security.DEBUG: Checking for authenticator support. {"firewall_name":"main","authenticators":2} []
[2023-10-05T17:52:37.097284+01:00] security.DEBUG: Checking support on authenticator. {"firewall_name":"main","authenticator":"App\Security\AdminAuthenticator"} []
[2023-10-05T17:52:37.097408+01:00] security.DEBUG: Authenticator does not support the request. {"firewall_name":"main","authenticator":"App\Security\AdminAuthenticator"} []
[2023-10-05T17:52:37.097512+01:00] security.DEBUG: Checking support on authenticator. {"firewall_name":"main","authenticator":"Symfony\Component\Security\Http\Authenticator\FormLoginAuthenticator"} []
[2023-10-05T17:52:37.097626+01:00] security.DEBUG: Authenticator does not support the request. {"firewall_name":"main","authenticator":"Symfony\Component\Security\Http\Authenticator\FormLoginAuthenticator"} []
[2023-10-05T17:52:39.246887+01:00] request.INFO: Matched route "_wdt". {"route":"_wdt","route_parameters":{"_route":"_wdt","_controller":"web_profiler.controller.profiler::toolbarAction","token":"37ef25"},"request_uri":"http://127.0.0.1:8000/_wdt/37ef25","method":"GET"} []
[2023-10-05T17:52:52.304542+01:00] request.INFO: Matched route "app_login". {"route":"app_login","route_parameters":{"_route":"app_login","_controller":"App\Controller\ConnexionController::login"},"request_uri":"http://127.0.0.1:8000/login","method":"POST"} []
[2023-10-05T17:52:52.318977+01:00] security.DEBUG: Checking for authenticator support. {"firewall_name":"main","authenticators":2} []
[2023-10-05T17:52:52.319150+01:00] security.DEBUG: Checking support on authenticator. {"firewall_name":"main","authenticator":"App\Security\AdminAuthenticator"} []
[2023-10-05T17:52:52.319961+01:00] security.DEBUG: Checking support on authenticator. {"firewall_name":"main","authenticator":"Symfony\Component\Security\Http\Authenticator\FormLoginAuthenticator"} []
[2023-10-05T17:52:52.367460+01:00] doctrine.INFO: Connecting with parameters array{"driver":"pdo_mysql","host":"127.0.0.1","port":3306,"user":"root","password":null,"driverOptions":[],"defaultTableOptions":[],"dbname":"ae","serverVersion":"10.4.28","charset":"utf8"} {"params":{"driver":"pdo_mysql","host":"127.0.0.1","port":3306,"user":"root","password":null,"driverOptions":[],"defaultTableOptions":[],"dbname":"ae","serverVersion":"10.4.28","charset":"utf8"}} []
[2023-10-05T17:52:52.952523+01:00] doctrine.DEBUG: Executing statement: SELECT t0.id AS id_1, t0.email AS email_2, t0.roles AS roles_3, t0.password AS password_4, t0.name AS name_5, t0.last_name AS last_name_6, t0.name_profile_picture AS name_profile_picture_7, t0.update_at AS update_at_8, t0.created_at AS created_at_9 FROM user t0 WHERE t0.email = ? LIMIT 1 (parameters: array{"1":"franckagbokoudjo301@gmail.com"}, types: array{"1":2}) {"sql":"SELECT t0.id AS id_1, t0.email AS email_2, t0.roles AS roles_3, t0.password AS password_4, t0.name AS name_5, t0.last_name AS last_name_6, t0.name_profile_picture AS name_profile_picture_7, t0.update_at AS update_at_8, t0.created_at AS created_at_9 FROM user t0 WHERE t0.email = ? LIMIT 1","params":{"1":"franckagbokoudjo301@gmail.com"},"types":{"1":2}} []
[2023-10-05T17:52:54.169227+01:00] security.INFO: Authenticator successful! {"token":{"Symfony\Component\Security\Http\Authenticator\Token\PostAuthenticationToken":"PostAuthenticationToken(user=\"franckagbokoudjo301@gmail.com\", authenticated=true, roles=\"ROLE_ADMIN\")"},"authenticator":"App\Security\AdminAuthenticator"} []
[2023-10-05T17:52:54.198163+01:00] security.DEBUG: The "App\Security\AdminAuthenticator" authenticator set the response. Any later authenticator will not be called {"authenticator":"App\Security\AdminAuthenticator"} []
[2023-10-05T17:52:54.201976+01:00] security.DEBUG: Stored the security token in the session. {"key":"_security_main"} []
[2023-10-05T17:52:54.243656+01:00] doctrine.INFO: Disconnecting [] []
[2023-10-05T17:53:02.577678+01:00] security.DEBUG: Authenticator does not support the request. {"firewall_name":"main","authenticator":"Symfony\Component\Security\Http\Authenticator\FormLoginAuthenticator"} []
[2023-10-05T17:53:02.639502+01:00] security.DEBUG: Access denied, the user is not fully authenticated; redirecting to authentication entry point. {"exception":"[object] (Symfony\Component\Security\Core\Exception\AccessDeniedException(code: 403): Access Denied. at /home/febah/Documents/Academie/vendor/symfony/security-http/Firewall/AccessListener.php:132)"} []
[2023-10-05T17:53:02.640042+01:00] security.DEBUG: Calling Authentication entry point. [] []
[2023-10-05T17:53:02.770805+01:00] request.INFO: Matched route "app_login". {"route":"app_login","route_parameters":{"_route":"app_login","_controller":"App\Controller\ConnexionController::login"},"request_uri":"http://127.0.0.1:8000/login","method":"GET"} []
[2023-10-05T17:53:02.779515+01:00] security.DEBUG: Checking for authenticator support. {"firewall_name":"main","authenticators":2} []
[2023-10-05T17:53:02.779718+01:00] security.DEBUG: Checking support on authenticator. {"firewall_name":"main","authenticator":"App\Security\AdminAuthenticator"} []
[2023-10-05T17:53:02.779808+01:00] security.DEBUG: Authenticator does not support the request. {"firewall_name":"main","authenticator":"App\Security\AdminAuthenticator"} []
[2023-10-05T17:53:02.779920+01:00] security.DEBUG: Checking support on authenticator. {"firewall_name":"main","authenticator":"Symfony\Component\Security\Http\Authenticator\FormLoginAuthenticator"} []
[2023-10-05T17:53:02.780012+01:00] security.DEBUG: Authenticator does not support the request. {"firewall_name":"main","authenticator":"Symfony\Component\Security\Http\Authenticator\FormLoginAuthenticator"} []
[2023-10-05T17:53:03.170159+01:00] request.INFO: Matched route "_wdt". {"route":"_wdt","route_parameters":{"_route":"_wdt","_controller":"web_profiler.controller.profiler::toolbarAction","token":"81199c"},"request_uri":"http://127.0.0.1:8000/_wdt/81199c","method":"GET"} []
'
Ce que je veux
Mes ainés je vous en prie de m'aider

Ce que j'obtiens

Décrivez vos éventuelles erreurs ou ce que vous obtenez à la place de ce que vous attendez :(

2 réponses


Les pages à colorier Bobbie Goods pour enfants constituent une excellente activité d'apprentissage que les enfants apprécieront et dont ils bénéficieront pleinement. Non seulement cela améliore la créativité et l’imagination, mais cela favorise également les compétences essentielles au développement telles que la motricité fine, les capacités cognitives et l’estime de soi. Les parents et les éducateurs peuvent intégrer ces pages à colorier dans leurs stratégies pédagogiques, rendant ainsi l'éducation amusante et engageante. https://coloringpageswk.com/others/bobbie-goods/

[quote]
Bonjour les ainés en Particulier l'administrateur Grafikart
En me connectant sur ma page administration de easyadmin lorsque je clique sur un lien ou sur boutton d'action je suis rediriger vers la page de connexion où on e demande de reconnecter à nouveau
voici le contenue mes fichiers:
secuity.yaml
security:
'nenable_authenticator_manager: true

https://symfony.com/doc/current/corel-security.html#registering-the-user-hashing-passwords
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'

https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider

providers:
app_userprovider:
entity:
class: App\Entity\Security\Admin\User
property: email
firewalls:
dev:
pattern: ^/(
(profiler|wdt)|css|images|js)/
security: false
main:
lazy: true
provider: app_user_provider
form_login:

"app_login" is the name of the route created previously
        login_path: app_login
        check_path: app_login
        default_target_path: admin
        always_use_default_target_path: true
        enable_csrf: true
    custom_authenticator: App\Security\AdminAuthenticator
    entry_point: App\Security\AdminAuthenticator
    logout:
        path: app_logout
        # where to redirect after logout
        # target: app_any_route

    # activate different ways to authenticate
    # https://symfony.com/doc/current/security.html#the-firewall

    # https://symfony.com/doc/current/security/impersonating_user.html
    # switch_user: true
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: ^/admin, roles: ROLE_ADMIN }
  • { path: ^/login, roles: PUBLIC_ACCESS }

    - { path: ^/profile, roles: ROLE_USER }

    when@test:
    security:
    password_hashers:

By default, password hashers are resource intensive and take time.
[/quote].

Y a-t-il une raison spécifique pour laquelle, en cliquant sur un lien ou un bouton d'action dans la page d'administration d'EasyAdmin, je suis redirigé vers la page de connexion pour une nouvelle authentification, et cela pourrait-il être lié à la configuration du fichier security.yaml fourni ?