amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Feature: Allowing any source-origin access to static config for AMP-Analytics

Open lintal opened this issue 9 years ago • 11 comments

What's the issue?

We are hitting an issue for our use-case where the AMP CORS requests requirements block access to a static JSON config file hosted for AMP-Analytics. The information contained in this file is not private in any way and could easily be determined/inferred through other means = there is no reason or benefit to us why access to this information should be restricted just for AMP-Analytics.

We would like to find a way to lift/bypass/disable the requirement for the "AMP-Access-Control-Allow-Source-Origin" HTTP Header for this type of scenario.

Use-case:

We syndicate content through many different partner websites (domains) and, as part of the contractual agreement we have with them, they agree to implement analytics tracking code reporting back to us.

Intent

We would like to use AMP-Analytics with a custom vendor configuration defined, so the tracking destination / metrics etc can be adjusted centrally. Ideally, the JSON configuration content will be static and hosted in an AWS S3 bucket.

For example, on a partner website: http://my-partner.com/path/to/amp/page the partner will implement the following code:

<amp-analytics config="https://our-domain.com/path/to/analytics-config.json"> ... </amp-analytics>

We want to keep this configuration centralised as we will be switching Analytics provider in the near future. Using a configuration hosted separately, this can be updated without updating every website connected to it.

Issue

We cannot set the "AMP-Access-Control-Allow-Source-Origin" required by the AMP-CORS-Requests spec without compute resource which incurs additional cost. As the source origin is external to us, AMP currently will block the request to the config file without this header being set.


Any input on this matter will be appreciated and/or any ideas regarding a solution to this within AMP. If further information is required, please let me know.

Thanks & BR Alex

lintal avatar Sep 22 '17 13:09 lintal

/to @cramforce

jridgewell avatar Sep 22 '17 21:09 jridgewell

Seems reasonable for config requests without credentials.

cramforce avatar Sep 22 '17 21:09 cramforce

Hi All

Given this ticket was dropped out of the October H2 sprint when it ended, is there any way to know when this can get picked back up? How can we assist to progress this ticket forward and/or to include this in another sprint? Do tickets not roll-forward into the next sprint if they aren't completed?

Thanks Alex

lintal avatar Nov 09 '17 11:11 lintal

We reprioritize every sprint, so it might not be added to the new spring. If you're interested in working on this yourself, it should be a simple change.

jridgewell avatar Nov 09 '17 21:11 jridgewell

Yes, let us know if you're interested to make the small change that should be required here.

Can anyone provide background on why CORS was required for this request in the first place?

rudygalfi avatar Nov 13 '17 19:11 rudygalfi

CORS is required to be able to read the response. lets remove the AMP CORS requirement when no credential access is requested.

cramforce avatar Nov 17 '17 12:11 cramforce

@cramforce I have 2 related questions:

  • why browser enforce CORS rules when request does not contain credential (need to understand if AMP CORS needs to respect that).
  • after the CURLS launch, is AMP CORS still needed?

lannka avatar Jan 12 '18 22:01 lannka

CORS is needed without credentials because reading content on other origins isn't allowed on the web by default.

We still need it after CURLS launch due to an oversight of missing the schema in the origin. We could get rid of it only for HTTPS source origin docs.

cramforce avatar Jan 12 '18 23:01 cramforce

We still need it after CURLS launch due to an oversight of missing the schema in the origin. We could get rid of it only for HTTPS source origin docs.

You meant for pages on origins with different schema:

https://amp.example.com/
http://amp.example.com/

Will have the same origin on cache server:

https://amp-example-com.cdn.ampproject.org/

hence pub server will not know if the page is from http or https.

lannka avatar Jan 13 '18 00:01 lannka

Right. @dvoytenko and I discussed that we could move towards "It was HTTPS unless we tell you otherwise"

cramforce avatar Jan 13 '18 00:01 cramforce

... because reading content on other origins isn't allowed on the web by default.

Given that, I think we should still have AMPCORS when request has no credential. We can disable AMPCORS for amp-analytics explicitly though, like what Yuxuan did in her PR: #12787.

Right. @dvoytenko and I discussed that we could move towards "It was HTTPS unless we tell you otherwise"

Right, that can simplify CORS integrations for pubs that treat the 2 schema the same.

lannka avatar Jan 13 '18 01:01 lannka