44
55use Symfony \Bundle \SecurityBundle \DependencyInjection \Security \Factory \AbstractFactory ;
66use Symfony \Component \DependencyInjection \ContainerBuilder ;
7- use Symfony \Component \DependencyInjection \DefinitionDecorator ;
87use Symfony \Component \DependencyInjection \ChildDefinition ;
98use Symfony \Component \DependencyInjection \Reference ;
109
@@ -18,7 +17,7 @@ public function __construct()
1817 $ this ->addOption ('user_factory ' );
1918 $ this ->addOption ('token_factory ' );
2019 $ this ->addOption ('persist_user ' , false );
21-
20+
2221 if (!isset ($ this ->options ['success_handler ' ])) {
2322 $ this ->options ['success_handler ' ] = 'hslavich_onelogin_saml.saml_authentication_success_handler ' ;
2423 }
@@ -60,8 +59,7 @@ protected function getListenerId()
6059 protected function createAuthProvider (ContainerBuilder $ container , $ id , $ config , $ userProviderId )
6160 {
6261 $ providerId = 'security.authentication.provider.saml. ' .$ id ;
63- $ definitionClassname = $ this ->getDefinitionClassname ();
64- $ definition = $ container ->setDefinition ($ providerId , new $ definitionClassname ('hslavich_onelogin_saml.saml_provider ' ))
62+ $ definition = $ container ->setDefinition ($ providerId , new ChildDefinition ('hslavich_onelogin_saml.saml_provider ' ))
6563 ->replaceArgument (0 , new Reference ($ userProviderId ))
6664 ->addArgument (array (
6765 'persist_user ' => $ config ['persist_user ' ]
@@ -79,44 +77,16 @@ protected function createAuthProvider(ContainerBuilder $container, $id, $config,
7977 return $ providerId ;
8078 }
8179
82- protected function createListener ($ container , $ id , $ config , $ userProvider )
83- {
84- $ listenerId = parent ::createListener ($ container , $ id , $ config , $ userProvider );
85- $ this ->createLogoutHandler ($ container , $ id , $ config );
86-
87- return $ listenerId ;
88- }
89-
9080 protected function createEntryPoint ($ container , $ id , $ config , $ defaultEntryPoint )
9181 {
9282 $ entryPointId = 'security.authentication.form_entry_point. ' .$ id ;
93- $ definitionClassname = $ this ->getDefinitionClassname ();
9483 $ container
95- ->setDefinition ($ entryPointId , new $ definitionClassname ('security.authentication.form_entry_point ' ))
84+ ->setDefinition ($ entryPointId , new ChildDefinition ('security.authentication.form_entry_point ' ))
9685 ->addArgument (new Reference ('security.http_utils ' ))
9786 ->addArgument ($ config ['login_path ' ])
9887 ->addArgument ($ config ['use_forward ' ])
9988 ;
10089
10190 return $ entryPointId ;
10291 }
103-
104- protected function createLogoutHandler ($ container , $ id , $ config )
105- {
106- if ($ container ->hasDefinition ('security.logout_listener. ' .$ id )) {
107- $ logoutListener = $ container ->getDefinition ('security.logout_listener. ' .$ id );
108- $ samlListenerId = 'hslavich_onelogin_saml.saml_logout ' ;
109-
110- $ definitionClassname = $ this ->getDefinitionClassname ();
111- $ container
112- ->setDefinition ($ samlListenerId , new $ definitionClassname ('saml.security.http.logout ' ))
113- ->replaceArgument (2 , array_intersect_key ($ config , $ this ->options ));
114- $ logoutListener ->addMethodCall ('addHandler ' , array (new Reference ($ samlListenerId )));
115- }
116- }
117-
118- private function getDefinitionClassname ()
119- {
120- return class_exists (ChildDefinition::class) ? ChildDefinition::class : DefinitionDecorator::class;
121- }
12292}
0 commit comments