Question

I am currently working on an app that is using the FosUserBundle and maintains a local database of users. The use case is as follows:

User tries to login and upon login the credentials are authenticated

In case of success the user proceeds to navigate the site

In case of failure above:

the credentials are authenticated against a single sign on service and if credentials are correct, the user is created locally, logged in, and proceeds to navigate the site.

In case the single sign on is unsuccessful, user is shown the default incorrect password screen

My question is where in Symfony would I add this logic?

This is what I have tried so far:

  1. I have tried to look at overrriding the loginAction however on further research I read that it may not work as it just dislays the login form.

  2. I looked at the following stackoverflow question: Overriding the authentication failure handler - Symfony2

  3. Also I read this in Symfony docs: http://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html

I am not clear as to whether I should use the approach in 2 or 3 in my use case. Any tips or code samples would be highly appreciated.

Was it helpful?

Solution

I ended up using a hybrid approach of 2 & 3 to solve my problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top