0
votes

I am using multiple users providers in my project.

My security.yml looks like this :

security:
  ...
  firewalls:
    usertype1:
       pattern: ^/root/usertype1_area
       provider: type1_provider
    usertype2
       pattern: ^/root
       provider: type2_provider
  ...

Everything is working fine and I can't login with wrong user types at the right pattern, except that I noticed that if I throw an exception in one of my providers, say type1_provider , and try to log in with the /root/login path (which should use only type2_provider), Symfony is going through type1_provider as well as type2_provider, and I get an exception.

The same is also true with /root/usertype1_area/login when I throw at type2_provider.

This is a problem to me because I want to be able to access type2 login when the type1_provider is shut down.

Any guesses ? Is this normal behavior ?

EDIT : As pointed out by Alexander Keil, it was not clear in my question what I was trying to do

One of my providers relies on a 3d party service, and I want it to throw when this service is down, but I still want to be able to access the other login, which is not supposed to rely on the provider that is throwing. Is there a way I can achieve this ?

1

1 Answers

0
votes

You can use the method "supportsClass" in your provider. Return false if the current user class does not support the loaded provider. See Symfony\Component\Security\Core\User\UserProviderInterface