Skip to content

Commit

Permalink
Merge pull request #412 from rubanooo/fix-token-header
Browse files Browse the repository at this point in the history
Fixed token header in explorer
  • Loading branch information
weisswurstkanone authored Aug 30, 2021
2 parents 51db221 + 8c9de8d commit 0249004
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Controller/GraphQLExplorerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
namespace Pimcore\Bundle\DataHubBundle\Controller;

use Pimcore\Bundle\DataHubBundle\GraphQL\Service;
use Pimcore\Bundle\DataHubBundle\Service\CheckConsumerPermissionsService;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -57,7 +58,7 @@ public function explorerAction(RouterInterface $routingService, Request $request

return $this->render('@PimcoreDataHub/Feature/explorer.html.twig', [
'graphQLUrl' => $url,
'tokenHeader' => 'access-token'
'tokenHeader' => CheckConsumerPermissionsService::TOKEN_HEADER
]);
}
}
4 changes: 3 additions & 1 deletion src/Service/CheckConsumerPermissionsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

class CheckConsumerPermissionsService
{
public const TOKEN_HEADER = 'X-API-Key';

/**
* @param Request $request
* @param Configuration $configuration
Expand All @@ -32,7 +34,7 @@ public function performSecurityCheck(Request $request, Configuration $configurat
if ($securityConfig['method'] === Configuration::SECURITYCONFIG_AUTH_APIKEY) {
$apiKey = $request->headers->get('apikey');
if (empty($apiKey)) {
$apiKey = $request->headers->get('X-API-Key');
$apiKey = $request->headers->get(static::TOKEN_HEADER);
}
if (empty($apiKey)) {
$apiKey = $request->get('apikey');
Expand Down

0 comments on commit 0249004

Please sign in to comment.