44
55namespace App \Authenticator ;
66
7- use App \Exception \SsoConsumerAuthNException ;
87use App \Exception \SsoConsumerException ;
98use OneLogin \Saml2 \Auth ;
109use Symfony \Component \HttpFoundation \JsonResponse ;
@@ -27,6 +26,8 @@ public function __construct(
2726 private readonly HttpUtils $ httpUtils ,
2827 private readonly string $ checkPath ,
2928 private readonly Auth $ auth ,
29+ private readonly string $ returnTo ,
30+ private readonly \Psr \Log \LoggerInterface $ logger ,
3031 ) {
3132 }
3233
@@ -44,10 +45,6 @@ public function authenticate(Request $request): Passport
4445 {
4546 $ session = $ request ->getSession ();
4647 $ authNRequestId = $ session ->get ('AuthNRequestID ' , null );
47- if (! \is_string ($ authNRequestId )) {
48- throw new SsoConsumerAuthNException ();
49- }
50-
5148 $ auth = $ this ->auth ;
5249 $ auth ->setStrict (false );
5350 $ auth ->processResponse ($ authNRequestId );
@@ -99,10 +96,12 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
9996 public function start (Request $ request , AuthenticationException |null $ authException = null )
10097 {
10198 $ session = $ request ->getSession ();
99+ $ this ->logger ->error ('Starting auth ' );
102100 $ auth = $ this ->auth ;
103- $ url = $ auth ->login (null , [], false , false , true );
101+ $ url = $ auth ->login ($ this -> returnTo , [], false , false , true );
104102 $ authNRequestId = $ auth ->getLastRequestID ();
105103 $ session ->set ('AuthNRequestID ' , $ authNRequestId );
104+ $ this ->logger ->error ("Need redirect to $ url " );
106105
107106 return new JsonResponse (['url ' => $ url ], Response::HTTP_UNAUTHORIZED );
108107 }
0 commit comments