Partage
  • Partager sur Facebook
  • Partager sur Twitter

Symfony 7 security.yaml hachage des mots de passe

Symfony 7 security.yaml hachage des mots de passe

Sujet résolu
    6 février 2024 à 19:00:34

    Bonjour à tous 

    En symfony 7,je suis en train de mettre en place le hachage des mots de passe quand mes users s'enregistre.

    Hors j'ai un soucis quand je fait un "php bin/console cache:clear" 

    Unrecognized option "app_user_provider" under "security.password_hashers.providers". Available options are "algorithm", "cost", "encode_as_b   

      ase64", "hash_algorithm", "id", "ignore_case", "iterations", "key_length", "memory_cost", "migrate_from", "time_cost". 


    Il me dise que il ne connait pas pas app_user_provider Hors, j'ai le réel sentiment que j'ai tout comme dans la documentation de Symfony. Voilà la documentation. https://symfony.com/doc/current/security.html#the-user


    Voila mon fichier config/packages.yaml :

    security:
      # https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
      password_hashers:
        # Use native password hasher, which auto-selects and migrates the best
        # possible hashing algorithm (which currently is "bcrypt")
        Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: "auto"
    
        providers:
          app_user_provider:
            entity:
              class: App\Entity\User
              property: email
    
      firewalls:
        dev:
          pattern: ^/(_(profiler|wdt)|css|images|js)/
          security: false
    
        main:
          lazy: true
          provider: app_user_provider
          custom_authenticator: App\Security\AppCustomAuthenticator
          logout:
            path: app_logout
            # where to redirect after logout
            # target: app_any_route
    
          remember_me:
            secret: "%kernel.secret%"
            lifetime: 604800
            path: /
            always_remember_me: true
    
    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
    










    • Partager sur Facebook
    • Partager sur Twitter
      8 février 2024 à 20:20:51

      Salut

      Le problème est que tu as mis un niveau d'indentation en trop aux lignes 8 à 12, ce qui fait qu'en YAML, c'est comme si elles étaient "sous" password_hashers.

      • Partager sur Facebook
      • Partager sur Twitter

      Symfony 7 security.yaml hachage des mots de passe

      × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
      • Editeur
      • Markdown