PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, February 28, 2022

[FIXED] Symfony 5.4 SecurityBundle, cant login after register

 February 28, 2022     authentication, php, security, symfony     No comments   

Issue

I build empty new project on 5.4 version, i use those commands to build project:

composer create-project symfony/skeleton:"^5.4" testapp54 &&
cd testapp54 &&
composer require webapp &&
composer require symfony/apache-pack &&
composer require symfonycasts/verify-email-bundle &&
composer require symfony/security-bundle &&
composer require symfonycasts/reset-password-bundle &&
php bin/console make:controller MainController &&
php bin/console make:user &&
php bin/console make:auth &&
php bin/console make:registration &&
php bin/console make:reset-password &&
php bin/console make:migration &&
php bin/console doctrine:migrations:migrate

After those install and config app working fine, i can even register, if i choose in conf option Do you want to automatically authenticate the user after registration? (yes/no) [yes]: on yes, i am logged after register. But if i logout and try login again i can't ! I dont have any errors even i put wrong credensials.

enter image description here


Solution

Back around 5.2, Symfony introduced yet another authentication system known as Http authentication. It's goal was to replace the older Guard authentication system.

The Authenticator class contains a supports method which basically detects when POST /login is being processed and kicks off the authentication process. If the method return false then no attempt at authentication is made.

In the newly introduced Http authentication system, the default supports method is not very robust. It works when using the symfony server:run webserver but fails for many other valid server configurations.

So if your authentication fails with no error messages then try overriding the supports method in your make:auth generated authenticator class with:

    public function supports(Request $request)
    {
        return self::LOGIN_ROUTE === $request->attributes->get('_route')
            && $request->isMethod('POST');
    }

And see if that helps. It's what the older Guard authenticator used to use. And feel free to comment on https://github.com/symfony/maker-bundle/issues/1056. Maybe we can get the maker folks to tweak their code.



Answered By - Cerad
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing