11
11
12
12
namespace LightSaml \SpBundle \Controller ;
13
13
14
- use Symfony \Bundle \FrameworkBundle \Controller \Controller ;
14
+ use LightSaml \Builder \Profile \Metadata \MetadataProfileBuilder ;
15
+ use LightSaml \Builder \Profile \WebBrowserSso \Sp \SsoSpSendAuthnRequestProfileBuilderFactory ;
16
+ use LightSaml \SymfonyBridgeBundle \Bridge \Container \PartyContainer ;
17
+ use LightSaml \SymfonyBridgeBundle \Bridge \Container \StoreContainer ;
18
+ use Symfony \Bundle \FrameworkBundle \Controller \AbstractController ;
15
19
use Symfony \Component \HttpFoundation \Request ;
16
20
17
- class DefaultController extends Controller
21
+ class DefaultController extends AbstractController
18
22
{
23
+ private MetadataProfileBuilder $ metadataProfileBuilder ;
24
+ private SsoSpSendAuthnRequestProfileBuilderFactory $ profileLoginFactory ;
25
+ private StoreContainer $ storeContainer ;
26
+ private PartyContainer $ partyContainer ;
27
+ private string $ discoveryRoute ;
28
+
29
+ public function __construct (
30
+ MetadataProfileBuilder $ metadataProfileBuilder ,
31
+ SsoSpSendAuthnRequestProfileBuilderFactory $ profileLoginFactory ,
32
+ StoreContainer $ storeContainer ,
33
+ PartyContainer $ partyContainer ,
34
+ string $ discoveryRoute
35
+ ) {
36
+ $ this ->metadataProfileBuilder = $ metadataProfileBuilder ;
37
+ $ this ->profileLoginFactory = $ profileLoginFactory ;
38
+ $ this ->storeContainer = $ storeContainer ;
39
+ $ this ->discoveryRoute = $ discoveryRoute ;
40
+ $ this ->partyContainer = $ partyContainer ;
41
+ }
42
+
19
43
public function metadataAction ()
20
44
{
21
- $ profile = $ this ->get ('ligthsaml.profile.metadata ' );
22
- $ context = $ profile ->buildContext ();
23
- $ action = $ profile ->buildAction ();
45
+ $ context = $ this ->metadataProfileBuilder ->buildContext ();
46
+ $ action = $ this ->metadataProfileBuilder ->buildAction ();
24
47
25
48
$ action ->execute ($ context );
26
49
@@ -29,7 +52,7 @@ public function metadataAction()
29
52
30
53
public function discoveryAction ()
31
54
{
32
- $ parties = $ this ->get ( ' lightsaml.container.build ' )-> getPartyContainer () ->getIdpEntityDescriptorStore ()->all ();
55
+ $ parties = $ this ->partyContainer ->getIdpEntityDescriptorStore ()->all ();
33
56
34
57
if (1 == count ($ parties )) {
35
58
return $ this ->redirect ($ this ->generateUrl ('lightsaml_sp.login ' , ['idp ' => $ parties [0 ]->getEntityID ()]));
@@ -44,10 +67,10 @@ public function loginAction(Request $request)
44
67
{
45
68
$ idpEntityId = $ request ->get ('idp ' );
46
69
if (null === $ idpEntityId ) {
47
- return $ this ->redirect ($ this ->generateUrl ($ this ->container -> getParameter ( ' lightsaml_sp.route.discovery ' ) ));
70
+ return $ this ->redirect ($ this ->generateUrl ($ this ->discoveryRoute ));
48
71
}
49
72
50
- $ profile = $ this ->get ( ' ligthsaml.profile.login_factory ' ) ->get ($ idpEntityId );
73
+ $ profile = $ this ->profileLoginFactory ->get ($ idpEntityId );
51
74
$ context = $ profile ->buildContext ();
52
75
$ action = $ profile ->buildAction ();
53
76
@@ -58,7 +81,7 @@ public function loginAction(Request $request)
58
81
59
82
public function sessionsAction ()
60
83
{
61
- $ ssoState = $ this ->get ( ' lightsaml.container.build ' )-> getStoreContainer () ->getSsoStateStore ()->get ();
84
+ $ ssoState = $ this ->storeContainer ->getSsoStateStore ()->get ();
62
85
63
86
return $ this ->render ('@LightSamlSp/sessions.html.twig ' , [
64
87
'sessions ' => $ ssoState ->getSsoSessions (),
0 commit comments