0

when symfony2 authenticates user by login form, an event security.authentication.success is fired and is handled by DefaultAuthenticationSuccessHandler. Constructor of this object takes two arguments HttpUtils $httpUtils and array $options. Variable $options is not empty and contains configuration options from security.yml like:

login_path => pkr_blog_admin_login
user_referer => false
...

I created a service AuthenticationSuccessHandler that extends DefaultAuthenticationSuccessHandler but can't find a way to pass values from security.yml as $options to constructor of my object. How can I do this?

I had tried using xdebug step by step debugging to see how those options are passed to DefaultAuthenticationSuccessHandler but couldn't find exact place in code :/

//EDIT

I found out that this configuration is set in src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php and only for default handler.

Here are some comments about not getting configuration from security.yml in custom handler:

https://github.com/symfony/symfony/issues/5432
https://github.com/symfony/symfony/issues/5488

Anyone know a way to get configuration parsed and ready to use by default handler from within my handler?

I suppose that it might be done by passing service container to my handler. I'll try this when I'll be back from work.

piotrekkr
  • 2,785
  • 2
  • 21
  • 35

1 Answers1

1

It seems that only way to make it work is to use compiler pass and change default handler class. See my similar question:

Better way of doing this is to use service as event handler:

Symfony2 extending DefaultAuthenticationSuccessHandler

Community
  • 1
  • 1
piotrekkr
  • 2,785
  • 2
  • 21
  • 35