-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
153 additions
and
2 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,151 @@ | ||
<?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\EuLoginBundle\Cas; | ||
|
||
use EcPhp\CasBundle\Cas\SymfonyCasInterface; | ||
use EcPhp\CasLib\Contract\CasInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
final class SymfonyECas implements SymfonyCasInterface | ||
{ | ||
private CasInterface $cas; | ||
|
||
private HttpMessageFactoryInterface $httpMessageFactory; | ||
|
||
public function __construct( | ||
CasInterface $cas, | ||
HttpMessageFactoryInterface $httpMessageFactory | ||
) { | ||
$this->cas = $cas; | ||
$this->httpMessageFactory = $httpMessageFactory; | ||
} | ||
|
||
public function authenticate( | ||
ServerRequestInterface|Request $request, | ||
array $parameters = [] | ||
): array { | ||
return $this | ||
->cas | ||
->authenticate( | ||
$this->updateRequest($request), | ||
$parameters | ||
); | ||
} | ||
|
||
public function handleProxyCallback( | ||
ServerRequestInterface|Request $request, | ||
array $parameters = [] | ||
): ResponseInterface { | ||
return $this | ||
->cas | ||
->handleProxyCallback( | ||
$this->updateRequest($request), | ||
$parameters | ||
); | ||
} | ||
|
||
public function login( | ||
ServerRequestInterface|Request $request, | ||
array $parameters = [] | ||
): ResponseInterface { | ||
return $this | ||
->cas | ||
->login( | ||
$this->updateRequest($request), | ||
$parameters | ||
); | ||
} | ||
|
||
public function logout( | ||
ServerRequestInterface|Request $request, | ||
array $parameters = [] | ||
): ResponseInterface { | ||
return $this | ||
->cas | ||
->logout( | ||
$this->updateRequest($request), | ||
$parameters | ||
); | ||
} | ||
|
||
public function process( | ||
ServerRequestInterface|Request $request, | ||
RequestHandlerInterface $handler | ||
): ResponseInterface { | ||
return $this | ||
->cas | ||
->process( | ||
$this->updateRequest($request), | ||
$handler | ||
); | ||
} | ||
|
||
public function requestProxyTicket( | ||
ServerRequestInterface|Request $request, | ||
array $parameters = [] | ||
): ResponseInterface { | ||
return $this | ||
->cas | ||
->requestProxyTicket( | ||
$this->updateRequest($request), | ||
$parameters | ||
); | ||
} | ||
|
||
public function requestServiceValidate( | ||
ServerRequestInterface|Request $request, | ||
array $parameters = [] | ||
): ResponseInterface { | ||
return $this | ||
->cas | ||
->requestServiceValidate( | ||
$this->updateRequest($request), | ||
$parameters | ||
); | ||
} | ||
|
||
public function requestTicketValidation( | ||
ServerRequestInterface|Request $request, | ||
array $parameters = [] | ||
): ResponseInterface { | ||
return $this | ||
->cas | ||
->requestTicketValidation( | ||
$this->updateRequest($request), | ||
$parameters | ||
); | ||
} | ||
|
||
public function supportAuthentication( | ||
ServerRequestInterface|Request $request, | ||
array $parameters = [] | ||
): bool { | ||
return $this | ||
->cas | ||
->supportAuthentication( | ||
$this->updateRequest($request), | ||
$parameters | ||
); | ||
} | ||
|
||
private function updateRequest( | ||
ServerRequestInterface|Request $request | ||
): ServerRequestInterface { | ||
return $request instanceof Request | ||
? $this->httpMessageFactory->createRequest($request) | ||
: $request; | ||
} | ||
} |
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