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.

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.