-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-view-transitions-2] Support same-site cross-origin view transitions #10364
Comments
If we're ok with script to start with (since |
Note also that |
Good point! Can you think of any issues with relaxing the restriction, if the site has a vt opt-in? |
How about adding a new Content Security Policy (CSP) directive for this instead? Sebastian |
Love it! Especially with the example of
Different-site cross-origin is fundamentally harder to do for multiple other reasons:
This is not to say cross-site is completely infeasible, but it needs a deeper dive into what control we actually want to give to authors vs letting majority of the experience to be defined by the UA. |
The vt opt in itself is not enough because you can't read it in the old page before the new page is parsed. CSP is perhaps more suitable because it can be delivered in HTTP headers. But the main restriction that's going to have to be relaxed is on navigation API session history, as for effective cross-doc navs you need to know where you're going to post-redirects and also where you came from (which might not be the referrer if you're traversing). Currently all of this is same-origin. There are not many things that are same-site protected and it's challenging to get right. I can't tell if a CSP opt-in is enough for this, it's a good conversation to have with security folks. My point is if we were to do this I would start from history and derive view transitions from that rather than jump straight to CSS. |
Note that CSP is designed as an opt-out only, meaning any added policy can only be further restricting what precedes it or the default. It's not a good framework for something that's supposed to be restricted by default and relaxed using an opt-in. |
That's fair. We might need 2 policies, one to allow same-site URLs to be visible in the navigation API session history and another for view-transition. And the view-transition can't apply without a navigation API opt-in.
Can you expand on "designed as an opt-out only"? Since on the surface it looks like a key -> list of URLs, it's not obvious why that list can't be used as an allow list on top of any same-origin URL. |
CSP is a list of policies, each policy with multiple directives. Every policy can only tighten what's before it, not relax it. It's built in a way that a policy injected (eg in a CDN header) can't relax security beyond the current state. |
My gut reaction was to have an opt-in through CSS, as not all authors have control over setting the headers. @view-transition {
navigation: auto;
origins: a.example.com, b.example.com; /* Or maybe even `*.example.com`? */
} I would prefer to explicitly list the origins here, so that in the future – if it ever would become a thing – cross-origin VTs can use the same descriptor to include other sites. @view-transition {
navigation: auto;
origins: *.example.com, *.example.org;
} (Note: I’m not suggesting to add cross-site support here and now; am merely thinking ahead to make sure the syntax can support that, if needed) An alternative would be to allow a combination of the values
|
Do I understand correctly that this would require I think that's probably doable if both origins consent to it, but it would be important to note that some of the information on We would also need to think carefully about |
Yes, the Document would need this information to customize the transition.
Can you expand on this a bit more? My thinking was that an opt-in from 2 same-site cross-origin URLs means we can expose all the information that is provided by the navigation API to same-origin URLs. Is there a reason we shouldn't do that? And specifically about your comment for |
A path forward to allowing this could be to expand on what we can do declaratively, and then restrict the JS access to the transition if it's cross-origin.
In essence, do the following:
|
The cross-document spec currently limits transitions to Document in the same-origin. This misses a common use-case of transitions on same-site cross-origin navigations: a.example.com -> b.example.com.
Since there is a security boundary between each origin, and transitions require sending the captured element data from the old Document to the new Document, this can't be done by default. But it should be feasible if both Documents opt-in to transitions from each other.
The above can likely be added to the
@view-transition
rule using 2 descriptors:from
/to
. Where the descriptor provides the URLs for Documents which it permits transitions from or to. The default value (same-origin
?) would limit to only same-origin URLs. Something like on a.example.com:The idea of
from
/to
was discussed on #8925 and this is a good use-case which needs it.We can also add a keyword like
same-site
to opt-in to transitions from/to any same-site URL.@vmpstr @noamr @bramus @jakearchibald @nt1m
The text was updated successfully, but these errors were encountered: