Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
r3h6 committed Sep 22, 2024
1 parent c7f495b commit ccdf486
Show file tree
Hide file tree
Showing 29 changed files with 270 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Classes/Domain/Model/FrontendUser.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the TYPO3 CMS project.
*
Expand Down
2 changes: 2 additions & 0 deletions Classes/Domain/Model/FrontendUserGroup.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the TYPO3 CMS project.
*
Expand Down
13 changes: 13 additions & 0 deletions Classes/Domain/Oauth/GrantTypes.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Domain\Oauth;

/***
*
* This file is part of the "OAuth2 Server" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2020
*
***/

enum GrantTypes: string
{
case AUTHORIZATION_CODE = 'authorization_code';
Expand Down
13 changes: 13 additions & 0 deletions Classes/Domain/Oauth/TokenTypes.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Domain\Oauth;

/***
*
* This file is part of the "OAuth2 Server" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2020
*
***/

enum TokenTypes: string
{
case ACCESS_TOKEN = 'access_token';
Expand Down
13 changes: 13 additions & 0 deletions Classes/Event/BeforeAssembleAuthorizationServerEvent.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Event;

use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
Expand All @@ -8,6 +10,17 @@
use League\OAuth2\Server\ResponseTypes\ResponseTypeInterface;
use R3H6\Oauth2Server\Configuration\Configuration;

/***
*
* This file is part of the "OAuth2 Server" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2020
*
***/

final class BeforeAssembleAuthorizationServerEvent
{
public function __construct(
Expand Down
13 changes: 13 additions & 0 deletions Classes/Event/FinalizeScopesEvent.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Event;

use League\OAuth2\Server\Entities\ClientEntityInterface;
use R3H6\Oauth2Server\Configuration\Configuration;

/***
*
* This file is part of the "OAuth2 Server" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2020
*
***/

final class FinalizeScopesEvent
{
public function __construct(
Expand Down
13 changes: 13 additions & 0 deletions Classes/Event/ModifyAuthenticationRedirectEvent.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Event;

use Psr\Http\Message\ResponseInterface;
use R3H6\Oauth2Server\Configuration\Configuration;
use R3H6\Oauth2Server\Mvc\Controller\AuthorizationContext;

/***
*
* This file is part of the "OAuth2 Server" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2020
*
***/

final class ModifyAuthenticationRedirectEvent
{
public function __construct(
Expand Down
13 changes: 13 additions & 0 deletions Classes/Event/ModifyAuthorizationServerRoutesEvent.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Event;

use R3H6\Oauth2Server\Configuration\Configuration;
use Symfony\Component\Routing\RouteCollection;

/***
*
* This file is part of the "OAuth2 Server" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2020
*
***/

final class ModifyAuthorizationServerRoutesEvent
{
public function __construct(
Expand Down
13 changes: 13 additions & 0 deletions Classes/Event/ModifyConsentRedirectEvent.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Event;

use Psr\Http\Message\ResponseInterface;
use R3H6\Oauth2Server\Configuration\Configuration;
use R3H6\Oauth2Server\Mvc\Controller\AuthorizationContext;

/***
*
* This file is part of the "OAuth2 Server" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2020
*
***/

final class ModifyConsentRedirectEvent
{
public function __construct(
Expand Down
13 changes: 13 additions & 0 deletions Classes/Event/ModifyResourceServerRoutesEvent.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Event;

use R3H6\Oauth2Server\Configuration\Configuration;
use Symfony\Component\Routing\RouteCollection;

/***
*
* This file is part of the "OAuth2 Server" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2020
*
***/

final class ModifyResourceServerRoutesEvent
{
public function __construct(
Expand Down
2 changes: 2 additions & 0 deletions Classes/Middleware/Dispatcher.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Middleware;

use League\OAuth2\Server\Exception\OAuthServerException;
Expand Down
19 changes: 12 additions & 7 deletions Classes/Middleware/Initializer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Middleware;

use League\OAuth2\Server\ResourceServer;
Expand Down Expand Up @@ -49,13 +51,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
return $handler->handle($request);
}

$this->logger->debug('Initializing oauth2 server');

$typoscript = GeneralUtility::makeInstance(FrontendTypoScript::class, new RootNode(), [], [], []);
$typoscript->setSetupArray([]);
$request = $request->withAttribute('frontend.typoscript', $typoscript);
$GLOBALS['TYPO3_REQUEST'] = $request;

$this->configuration->merge($this->extensionConfiguration->get('oauth2_server'));
$this->configuration->merge($siteConfiguration);

Expand All @@ -68,6 +63,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
return $handler->handle($request);
}

$request = $this->prepareExtbase($request);
$request = $request->withAttribute(RequestAttributes::OAUTH2_ROUTE, $route);

$validateAuthenticatedRequest = $route->getOptions()['oauth2_validateAuthenticatedRequest'] ?? true;
Expand All @@ -85,6 +81,15 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
return $handler->handle($request);
}

private function prepareExtbase(ServerRequestInterface $request): ServerRequestInterface
{
$typoscript = GeneralUtility::makeInstance(FrontendTypoScript::class, new RootNode(), [], [], []);
$typoscript->setSetupArray([]);
$request = $request->withAttribute('frontend.typoscript', $typoscript);
$GLOBALS['TYPO3_REQUEST'] = $request;
return $request;
}

private function processAuthorizationRequest(ServerRequestInterface $request): ServerRequestInterface
{
$this->logger->debug('Process authorization request');
Expand Down
11 changes: 11 additions & 0 deletions Classes/RequestAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

namespace R3H6\Oauth2Server;

/***
*
* This file is part of the "OAuth2 Server" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2020
*
***/

final class RequestAttributes
{
public const OAUTH2_ROUTE = 'oauth2.route';
Expand Down
2 changes: 2 additions & 0 deletions Classes/Routing/AbstractRouter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Routing;

use Psr\Http\Message\ServerRequestInterface;
Expand Down
2 changes: 2 additions & 0 deletions Classes/Routing/AuthorizationRouter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Routing;

use Psr\EventDispatcher\EventDispatcherInterface;
Expand Down
4 changes: 3 additions & 1 deletion Classes/Routing/ResourceRouter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Routing;

use Psr\EventDispatcher\EventDispatcherInterface;
Expand All @@ -17,7 +19,7 @@
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2020
* (c) 2024
*
***/

Expand Down
2 changes: 2 additions & 0 deletions Classes/Routing/RouterFactory.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Routing;

use Psr\EventDispatcher\EventDispatcherInterface;
Expand Down
2 changes: 2 additions & 0 deletions Classes/Routing/RouterInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Routing;

use Psr\Http\Message\ServerRequestInterface;
Expand Down
13 changes: 13 additions & 0 deletions Classes/Service/TokenService.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Service;

use Lcobucci\JWT\Encoding\JoseEncoder;
Expand All @@ -8,6 +10,17 @@
use League\OAuth2\Server\CryptTrait;
use R3H6\Oauth2Server\Domain\Oauth\TokenTypes;

/***
*
* This file is part of the "OAuth2 Server" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2020
*
***/

class TokenService
{
use CryptTrait;
Expand Down
2 changes: 2 additions & 0 deletions Classes/Session/Session.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Session;

use League\OAuth2\Server\RequestTypes\AuthorizationRequest;
Expand Down
13 changes: 13 additions & 0 deletions Tests/Functional/ApplicationTestCase.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
<?php

declare(strict_types=1);

namespace R3H6\Oauth2Server\Tests\Functional;

use Symfony\Component\Mailer\Transport\NullTransport;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

/***
*
* This file is part of the "OAuth2 Server" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2020
*
***/

abstract class ApplicationTestCase extends FunctionalTestCase
{
/**
Expand Down
Loading

0 comments on commit ccdf486

Please sign in to comment.