Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
GewoonYorick committed Apr 24, 2024
1 parent b4a6198 commit 7041c46
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
30 changes: 18 additions & 12 deletions src/Grant/AuthCodeGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface;
use League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface;
use League\OAuth2\Server\RequestTypes\AuthorizationRequest;
use League\OAuth2\Server\ResponseTypes\RedirectResponse;
use OpenIDConnect\Interfaces\CurrentRequestServiceInterface;
use Psr\Http\Message\ResponseInterface;

Expand All @@ -25,10 +24,16 @@ class AuthCodeGrant extends \League\OAuth2\Server\Grant\AuthCodeGrant
* @param RefreshTokenRepositoryInterface $refreshTokenRepository
* @param DateInterval $authCodeTTL
* @param ResponseInterface $psr7Response An empty PSR-7 Response object
* @param CurrentRequestServiceInterface $currentRequestService A service that returns the current request. Used to get the nonce parameter.
* @param CurrentRequestServiceInterface
* $currentRequestService A service that returns the current request. Used to get the nonce parameter.
* @throws \Exception
*/
public function __construct(AuthCodeRepositoryInterface $authCodeRepository, RefreshTokenRepositoryInterface $refreshTokenRepository, DateInterval $authCodeTTL, ResponseInterface $psr7Response, CurrentRequestServiceInterface $currentRequestService)
public function __construct(
AuthCodeRepositoryInterface $authCodeRepository,
RefreshTokenRepositoryInterface $refreshTokenRepository,
DateInterval $authCodeTTL,
ResponseInterface $psr7Response,
CurrentRequestServiceInterface $currentRequestService)
{
parent::__construct($authCodeRepository, $refreshTokenRepository, $authCodeTTL);
$this->psr7Response = $psr7Response;
Expand All @@ -48,7 +53,8 @@ public function completeAuthorizationRequest(AuthorizationRequest $authorization
$queryParams = $this->currentRequestService->getRequest()->getQueryParams();

if (isset($queryParams['nonce'])) {
// The only way to get the redirect URI is to generate the PSR7 response (The RedirectResponse class does not have a getter for the redirect URI)
// The only way to get the redirect URI is to generate the PSR7 response
// (The RedirectResponse class does not have a getter for the redirect URI)
$httpResponse = $response->generateHttpResponse($this->psr7Response);
$redirectUri = $httpResponse->getHeader('Location')[0];
$parsed = parse_url($redirectUri);
Expand Down Expand Up @@ -77,14 +83,14 @@ public function completeAuthorizationRequest(AuthorizationRequest $authorization
*/
private function unparse_url($parsed_url)
{
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
$host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
$port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
$user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
$pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
$pass = ($user || $pass) ? "$pass@" : '';
$path = isset($parsed_url['path']) ? $parsed_url['path'] : '';
$query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
$host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
$port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
$user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
$pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
$pass = ($user || $pass) ? "$pass@" : '';
$path = isset($parsed_url['path']) ? $parsed_url['path'] : '';
$query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
$fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
return "$scheme$user$pass$host$port$path$query$fragment";
}
Expand Down
1 change: 0 additions & 1 deletion src/Laravel/LaravelCurrentRequestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class LaravelCurrentRequestService implements CurrentRequestServiceInterface
{

public function getRequest(): ServerRequestInterface
{
return (new PsrHttpFactory(
Expand Down

0 comments on commit 7041c46

Please sign in to comment.