Allow switching/impersonating only to particular users in Symfony2

前端 未结 3 818
礼貌的吻别
礼貌的吻别 2020-12-09 12:51

EXPLANATION

Allowing user to switch to any other user is easy in Symfony2. My question is, how to allow certain user to switch only to certain other

3条回答
  •  情深已故
    2020-12-09 13:20

    You could possibly implement this type of thing by overriding the default SwitchUserListener.

    The parameter you would override is: security.authentication.switchuser_listener.class

    For example, in parameters.yml:

    parameters:
      security.authentication.switchuser_listener.class: My\Project\Security\Listener\SwitchUserListener
    

    Where, in your custom listener class, you'd implement Symfony\Component\Security\Http\Firewall\ListenerInterface and use the existing Symfony\Component\Security\Http\Firewall\SwitchUserListener class as a basis for your custom implementation.

提交回复
热议问题