BrandOriented / PimcoreCiHubConnector

This bundle adds full integration between Pimcore and CI-HUB Connector. Now you can add, delete and download all assets, lock and unlock, get all versions for specified asset and much more.
https://brandoriented.io/
Other
5 stars 6 forks source link

Then image thumbnail and image from inDesign does not work #23

Closed betterapp closed 7 months ago

betterapp commented 7 months ago

Pimcore version(s) affected

11

Description

We use inDesign to connect to Pimcore throw CI-HUB. When we list images from folder or want download image to inDesign

we see CI-HUB from inDesign try to make OPTIONS request to Pimcore: [01/Mar/2024:10:11:49 +0100] "OPTIONS /datahub/rest/jysk/asset/download?id=25&thumbnail=galleryThumbnail HTTP/1.1" 405

but we get error that route is not defined.

How to reproduce

Test the software

Possible Solution

  1. vendor/bo-hub/ci-hub-api-bundle/src/Controller/AssetController.php

Line 333: #[Route('/download', name: 'download', methods: ['GET'])] As we can see it does not allow OPTIONS methods

  1. If we add OPTIONS method for this Route we will get Authentication error
public function download(): Response
    {
        $crossOriginHeaders = [
            'Allow' => 'GET, OPTIONS',
            'Access-Control-Allow-Origin' => '*',
            'Access-Control-Allow-Methods' => 'GET, OPTIONS',
            'Access-Control-Allow-Headers' => 'authorization',
        ];

        // Send empty response for OPTIONS requests
        if ($this->request->isMethod('OPTIONS')) {
            return new Response('', 204, $crossOriginHeaders);
        }

if OPTIONS request the it should return 204 Respons. It does not because in Parent class BaseEndpointController __constructor we got

$this->user = $this->authManager->authenticate();

and this code throw error

I do not understand why OPTIONS request need authentication - it should not. I will prepare fix for it.

Additional Context

No response

betterapp commented 7 months ago

PR: https://github.com/BrandOriented/PimcoreCiHubConnector/pull/21

betterapp commented 7 months ago

@labudzinski can You merge changes and add 3.0.8 tag. thanks