Skip to content

Commit

Permalink
refactor: remove Symfony* Cas classes
Browse files Browse the repository at this point in the history
We use PSR requests directly in Controllers now.
  • Loading branch information
drupol committed May 8, 2023
1 parent fa17ff4 commit 13e30e6
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 326 deletions.
142 changes: 0 additions & 142 deletions src/Cas/SymfonyCas.php

This file was deleted.

66 changes: 0 additions & 66 deletions src/Cas/SymfonyCasInterface.php

This file was deleted.

34 changes: 0 additions & 34 deletions src/Cas/SymfonyCasResponseBuilder.php

This file was deleted.

26 changes: 0 additions & 26 deletions src/Cas/SymfonyCasResponseBuilderInterface.php

This file was deleted.

23 changes: 5 additions & 18 deletions src/Controller/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,20 @@

namespace EcPhp\CasBundle\Controller;

use EcPhp\CasBundle\Cas\SymfonyCasInterface;
use EcPhp\CasLib\Contract\CasInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Security;
use Throwable;

/**
* @deprecated Use a security entry point, see https://symfony.com/doc/current/security/entry_point.html
*/
final class Login
{
public function __invoke(
Request $request,
SymfonyCasInterface $cas,
Security $security
ServerRequestInterface $request,
CasInterface $cas
): RedirectResponse|ResponseInterface {
$parameters = $request->query->all() + [
'renew' => null !== $security->getUser(),
];

try {
$response = $cas
->login(
$request,
$parameters
);
$response = $cas->login($request);
} catch (Throwable) {
// TODO: Should we log the error ?
// If yes, we need to inject the LoggerInterface and require it
Expand Down
14 changes: 5 additions & 9 deletions src/Controller/Logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,24 @@

namespace EcPhp\CasBundle\Controller;

use EcPhp\CasBundle\Cas\SymfonyCasInterface;
use EcPhp\CasLib\Contract\CasInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Throwable;

final class Logout
{
public function __invoke(
Request $request,
SymfonyCasInterface $cas,
ServerRequestInterface $request,
CasInterface $cas,
Security $security,
TokenStorageInterface $tokenStorage
): ResponseInterface|RedirectResponse {
try {
$response = $cas
->logout(
$request,
$request->query->all()
);
$response = $cas->logout($request);
} catch (Throwable) {
// TODO: Should we log the error ?
// If yes, we need to inject the LoggerInterface and require it
Expand Down
14 changes: 5 additions & 9 deletions src/Controller/ProxyCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,20 @@

namespace EcPhp\CasBundle\Controller;

use EcPhp\CasBundle\Cas\SymfonyCasInterface;
use EcPhp\CasLib\Contract\CasInterface;
use Psr\Http\Message\ResponseInterface;
use Symfony\Component\HttpFoundation\Request;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\HttpFoundation\Response;
use Throwable;

final class ProxyCallback
{
public function __invoke(
Request $request,
SymfonyCasInterface $cas
ServerRequestInterface $request,
CasInterface $cas
): ResponseInterface|Response {
try {
$response = $cas
->handleProxyCallback(
$request,
$request->query->all()
);
$response = $cas->handleProxyCallback($request);
} catch (Throwable) {
return new Response('', 500);
}
Expand Down
Loading

0 comments on commit 13e30e6

Please sign in to comment.