File tree Expand file tree Collapse file tree
src/Storefront/Controller Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414use Symfony \Component \HttpFoundation \JsonResponse ;
1515use Symfony \Component \HttpFoundation \Request ;
1616use Symfony \Component \HttpFoundation \Response ;
17+ use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
1718use Symfony \Component \Routing \Annotation \Route ;
1819
1920#[Route(defaults: ['_routeScope ' => ['storefront ' ]])]
@@ -39,9 +40,22 @@ public function execute(
3940 ClientBuilder $ clientBuilder ,
4041 EventDispatcherInterface $ eventDispatcher ,
4142 ): Response {
43+ if (!$ this ->config ->isProxyEnabled ()) {
44+ throw new NotFoundHttpException ('Proxy is disabled. ' );
45+ }
46+
47+ $ apiKey = $ request ->headers ->get ('x-ff-api-key ' );
48+
49+ if (!$ apiKey ) {
50+ return new JsonResponse (
51+ ['message ' => 'UNAUTHORIZED ' ],
52+ Response::HTTP_UNAUTHORIZED
53+ );
54+ }
55+
4256 $ client = $ clientBuilder
4357 ->withServerUrl ($ this ->config ->getServerUrl () . '/ ' )
44- ->withApiKey ($ this -> config -> getApiKey () )
58+ ->withApiKey ($ apiKey )
4559 ->withVersion ($ this ->config ->getVersion ())
4660 ->build ();
4761 $ query = (string ) parse_url ($ _SERVER ['REQUEST_URI ' ] ?? '' , PHP_URL_QUERY );
You can’t perform that action at this time.
0 commit comments