This bundle provides impersonating feature (switch user) for API use.
Install this bundle through Composer:
composer require lafourchette/switch-user-stateless-bundle
Then, update your AppKernel.php file as following:
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
// ...
new SwitchUserStatelessBundle\SwitchUserStatelessBundle(),
];
Load routing in app/config/routing.yml
:
switch_user_stateless:
resource: "@SwitchUserStatelessBundle/Controller/ProfileController.php"
type: annotation
Finally, update your firewalls in your app/config/security.yml
file as following:
security:
firewalls:
main:
# ...
stateless: true
switch_user_stateless: true