Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Classes/GraphQL/Middleware/GraphQLMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
use Neos\Flow\Log\ThrowableStorageInterface;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Persistence\PersistenceManagerInterface;
use Neos\Flow\Security\Authentication\AuthenticationManagerInterface;
use Neos\Flow\Security\Context;
use Neos\Flow\Security\Exception\AuthenticationRequiredException;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -66,6 +68,7 @@ public function __construct(
private readonly ContainerInterface $serviceLocator,
private readonly CustomResolvers $customResolvers,
private readonly PersistenceManagerInterface $persistenceManager,
private readonly AuthenticationManagerInterface $authenticationManager,
) {
}

Expand All @@ -78,9 +81,10 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
}
if ($this->simulateControllerObjectName !== null) {
$mockActionRequest = ActionRequest::fromHttpRequest($request);
// Simulate a request to the specified controller to trigger authentication
// Simulate a request to the specified controller
$mockActionRequest->setControllerObjectName($this->simulateControllerObjectName);
$this->securityContext->setRequest($mockActionRequest);
$this->authenticationManager->isAuthenticated(); // Trigger authentication if isAuthenticated is null
}
$response = $this->responseFactory->createResponse();
$response = $this->addCorsHeaders($response);
Expand Down
3 changes: 3 additions & 0 deletions Classes/GraphQL/Middleware/GraphQLMiddlewareFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Neos\Flow\Log\ThrowableStorageInterface;
use Neos\Flow\ObjectManagement\ObjectManagerInterface;
use Neos\Flow\Persistence\PersistenceManagerInterface;
use Neos\Flow\Security\Authentication\AuthenticationManagerInterface;
use Neos\Flow\Security\Context;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
Expand All @@ -40,6 +41,7 @@ public function __construct(
private readonly ObjectManagerInterface $objectManager,
private readonly CustomResolversFactory $customResolversFactory,
private readonly PersistenceManagerInterface $persistenceManager,
private readonly AuthenticationManagerInterface $authenticationManager,
) {
}

Expand All @@ -65,6 +67,7 @@ public function create(
$this->objectManager,
$this->customResolversFactory->create($customResolversSettings ?? []),
$this->persistenceManager,
$this->authenticationManager,
);
}
}