Skip to content

Commit

Permalink
feat: add a CAS Authentication Entry Point
Browse files Browse the repository at this point in the history
This let people gets redirected to the page where they comes from once they are authenticated.

(cherry picked from commit 173dc52)
  • Loading branch information
drupol committed Feb 28, 2023
1 parent 77e96a0 commit 1cd8abb
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/Security/CasAuthenticationEntryPoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://github.com/ecphp
*/

declare(strict_types=1);

namespace EcPhp\CasBundle\Security;

use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;

final class CasAuthenticationEntryPoint extends AuthenticationEntryPointInterface
{
private UrlGeneratorInterface $urlGenerator;

public function __construct(UrlGeneratorInterface $urlGenerator)
{
$this->urlGenerator = $urlGenerator;
}

public function start(Request $request, AuthenticationException $authException = null): RedirectResponse
{
return new RedirectResponse(
$this
->urlGenerator
->generate(
'cas_bundle_login',
$request->query->all() + ['service' => $request->getUri()],
);
);

}
}

0 comments on commit 1cd8abb

Please sign in to comment.