magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Maps element not working - Page Builder missing appropriate CSP whitelist rules #38286

Open adamlavery opened 11 months ago

adamlavery commented 11 months ago

Preconditions and environment

Magento OS 2.4.6

Steps to reproduce

  1. Add a Map element to Page Builder

Expected result

Map should work and render correctly.

Actual result

Map doesn't work and doesn't render correctly in backend. Map doesn't work on frontend.

Additional information

Issue 1 is that Page Builder CSP whitelist is missing many CSP rules required for Google Maps to work correctly. This is how it should be:

<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
    <policies>
        <policy id="connect-src">
            <values>
                <value id="vimeo" type="host">vimeo.com</value>
                <value id="google-maps" type="host">maps.googleapis.com</value>
            </values>
        </policy>
        <policy id="frame-src">
            <values>
                <value id="youtube" type="host">*.youtube.com</value>
                <value id="youtube_nocookie" type="host">*.youtube-nocookie.com</value>
            </values>
        </policy>
        <policy id="script-src">
            <values>
                <value id="google-maps" type="host">maps.googleapis.com</value>
            </values>
        </policy>
        <policy id="img-src">
            <values>
                <value id="google-img-static" type="host">*.gstatic.com</value>
                <value id="google-img-apis" type="host">*.googleapis.com</value>
            </values>
        </policy>
        <policy id="style-src">
            <values>
                <value id="google-css-staic" type="host">*.gstatic.com</value>
                <value id="google-css-apis" type="host">*.googleapis.com</value>
            </values>
        </policy>
    </policies>
</csp_whitelist>

Issue 2 is that latest Google Maps API fails due to overriding Array.from() in vendor\magento\magento2-base\lib\web\legacy-build.min.js. That has to be removed for the API to function correctly.

Release note

No response

Triage and priority

m2-assistant[bot] commented 11 months ago

Hi @adamlavery. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

adamlavery commented 11 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 11 months ago

Hi @adamlavery. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 11 months ago

Hi @adamlavery, here is your Magento Instance: https://16b86c0cc2f70973ea7db7c4aae7acfd.instances-prod.magento-community.engineering Admin access: https://16b86c0cc2f70973ea7db7c4aae7acfd.instances-prod.magento-community.engineering/admin_8ed2 Login: 45180ae5 Password: 6f73ad744e47

adamlavery commented 11 months ago

Issue confirmed:

image

m2-assistant[bot] commented 11 months ago

Hi @engcom-Bravo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Bravo commented 11 months ago

Hi @adamlavery,

Thank you for reporting and collaboration.

Verified the issue on Magento 2.4-develop instance and the issue is reproducible.Kindly refer the screenshots.

Steps to reproduce

Screenshot from 2023-12-15 11-46-20

Map doesn't work and doesn't render correctly in backend. Map doesn't work on frontend.

Hence Confirming the issue.

Thanks.

github-jira-sync-bot commented 11 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-10704 is successfully created for this GitHub issue.

m2-assistant[bot] commented 11 months ago

:white_check_mark: Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

pagesailor commented 8 months ago

When will be a fix available for this? Prototype.js array.from implementation conflicts with Google maps API from v3.54. Forcing maps API version v3.53 was a viable workaround, but in 2024 april that version will be officially deprecated, causing all google maps implementations on Magento 2 to stop working. Considering that a minor Magento 2 version upgrade can take weeks or months (depending on the complexity of a project), any fix for this is already late. But still, if there will be an official fix for this, when will it be, and is it going to be backported? Are there any viable workarounds for this?

alitopaloglu commented 7 months ago

I've just applied a workaround to get rid of this issue by forcing to use the exact version of Google maps API v3.53. Thanks to @pagesailor

pagesailor commented 7 months ago

@alitopaloglu keep in mind that this workaround won't work after the middle of 2024 may, when the 3.53 Goole Maps API version will be retired.

Djohn12 commented 3 months ago

Seems an official patch is now available: https://experienceleague.adobe.com/en/docs/commerce-knowledge-base/kb/troubleshooting/site-down-or-unresponsive/revised-patches-for-google-maps-access-loss-on-all-adobe-commerce-versions

It looks ok at first glance, will try it soon to see if it works as expected