-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a CAS Authentication Entry Point
This let people gets redirected to the page where they comes from once they are authenticated. (cherry picked from commit 173dc52)
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()], | ||
); | ||
); | ||
|
||
} | ||
} |