diff --git a/composer.json b/composer.json index 26ad77d9..7be9c79f 100644 --- a/composer.json +++ b/composer.json @@ -49,8 +49,8 @@ }, "require": { "php": "~8.2.0 || ~8.3.0", - "ext-json": "*", "ext-gd": "*", + "ext-json": "*", "dotkernel/dot-annotated-services": "^4.1.7", "dotkernel/dot-cache": "^4.0", "dotkernel/dot-cli": "^3.5.0", @@ -78,7 +78,8 @@ "mezzio/mezzio-twigrenderer": "^2.15.0", "ramsey/uuid-doctrine": "^2.0.0", "roave/psr-container-doctrine": "^4.1.0", - "symfony/filesystem": "^7.0.3" + "symfony/filesystem": "^7.0.3", + "symfony/var-exporter": "^6.4 || ^7.4" }, "require-dev": { "laminas/laminas-coding-standard": "^2.5", diff --git a/src/App/src/ConfigProvider.php b/src/App/src/ConfigProvider.php index bd5d44d0..ea492686 100644 --- a/src/App/src/ConfigProvider.php +++ b/src/App/src/ConfigProvider.php @@ -7,7 +7,6 @@ use Api\App\Command\RouteListCommand; use Api\App\Command\TokenGenerateCommand; use Api\App\Entity\EntityListenerResolver; -use Api\App\Factory\AuthenticationMiddlewareFactory; use Api\App\Factory\EntityListenerResolverFactory; use Api\App\Factory\RouteListCommandFactory; use Api\App\Factory\TokenGenerateCommandFactory; @@ -63,7 +62,7 @@ public function getDependencies(): array 'doctrine.entity_manager.orm_default' => EntityManagerFactory::class, 'dot-mail.options.default' => MailOptionsAbstractFactory::class, 'dot-mail.service.default' => MailServiceAbstractFactory::class, - AuthenticationMiddleware::class => AuthenticationMiddlewareFactory::class, + AuthenticationMiddleware::class => AnnotatedServiceFactory::class, AuthorizationMiddleware::class => AnnotatedServiceFactory::class, ContentNegotiationMiddleware::class => AnnotatedServiceFactory::class, Environment::class => TwigEnvironmentFactory::class, diff --git a/src/App/src/Middleware/AuthenticationMiddleware.php b/src/App/src/Middleware/AuthenticationMiddleware.php index 25ac3c81..a714bdbc 100644 --- a/src/App/src/Middleware/AuthenticationMiddleware.php +++ b/src/App/src/Middleware/AuthenticationMiddleware.php @@ -6,13 +6,26 @@ use Api\App\UserIdentity; use Api\User\Entity\UserRole; +use Dot\AnnotatedServices\Annotation\Inject; +use Mezzio\Authentication\AuthenticationInterface; use Mezzio\Authentication\UserInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; -class AuthenticationMiddleware extends \Mezzio\Authentication\AuthenticationMiddleware +class AuthenticationMiddleware implements MiddlewareInterface { + /** + * @Inject({ + * AuthenticationInterface::class, + * }) + */ + public function __construct( + protected AuthenticationInterface $auth, + ) { + } + public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $user = $this->auth->authenticate($request);