Skip to content

Commit

Permalink
fix: update start method
Browse files Browse the repository at this point in the history
Do not use a redirect response or else some informations are lost.

(cherry picked from commit f3ebf70)
  • Loading branch information
drupol committed Mar 1, 2023
1 parent 50d5eee commit e09e56c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Security/CasAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
use EcPhp\CasLib\Utils\Uri;
use InvalidArgumentException;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Bridge\PsrHttpMessage\HttpFoundationFactoryInterface;
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\User\UserInterface;
Expand All @@ -36,9 +36,9 @@ final class CasAuthenticator extends AbstractAuthenticator implements Authentica
{
public function __construct(
private CasInterface $cas,
private HttpMessageFactoryInterface $httpMessageFactory,
private CasUserProviderInterface $userProvider,
private UrlGeneratorInterface $urlGenerator
private HttpFoundationFactoryInterface $httpFoundationFactory,
private HttpMessageFactoryInterface $httpMessageFactory,
) {
}

Expand Down Expand Up @@ -112,13 +112,13 @@ public function start(Request $request, ?AuthenticationException $authException
);
}

return new RedirectResponse(
$this
->urlGenerator
->generate(
'cas_bundle_login',
)
);
// Here we could also forward the request to `cas_bundle_login`.
// Maybe this is something we should do at some point.
$response = $this->cas->login($request->query->all());

return null === $response ?
new RedirectResponse('/') :
$this->httpFoundationFactory->createResponse($response);
}

public function supports(Request $request): bool
Expand Down

0 comments on commit e09e56c

Please sign in to comment.