Symfony2: FOSUserBundle - Single firewall, multiple entry forms / entry points

I have a symfony2 application working with a single firewall configured with FOSUserBundle to handle ongoing user support. It works great.

However, I want to have no more than one login form / page. I need a "standard" / login page that is used by the firewall, but I also want to embed forms on other pages for easier access to the account.

For example, on the page / booking / require _login, I tried to implement the login form template from FOSUserBundle, which is quite simple. I set _target_path to succeed. However, if this is a failed login attempt, I will be redirected back to the standard / registration form, and will not stay on my page / booking / require _login for visualization with corresponding errors. I see that there is a failure_path parameter, but it looks like something global, and not something that you can pass as the _target_path parameter.

It seems to me that I'm probably pushing the hacker approach further than it can go.

I do not need a separate firewall, this is just an alternative way to access the same login with the same set of restrictions.

Can anyone suggest any pointers to a clean (or simple!) Approach?

+4
source share
1 answer

You can introduce a failure handler (implement AuthenticationFailureHandlerInterface ) where you can create a redirect based on the Request data (for example, redirect to url based on the post_pass_path parameter).

And it is very easy to enter, you just need to create a service called security.authentication.failure_handler in your DIC configuration.

+2
source

Source: https://habr.com/ru/post/1384276/


All Articles