-
Notifications
You must be signed in to change notification settings - Fork 23
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
URI in Profile triggers CORS Unsafe Request Header Byte rule #436
Comments
You say "NOT CORS safe", but I think the issue is the header will not be "CORS-safelisted"? When that is the case, a preflight request will be used. If that succeeds, the request should be sent. This doesn't seem like a blocker for using any of these headers, just a bit more server complexity than the "simple requests" CORS case that doesn't do a preflight. You probably need to setup a Access-Control-Allow-Headers to allow Accept, others as needed, and probably want Access-Control-Max-Age to cache preflight requests if appropriate. @pchampin had a w3id.org issue with CORS and preflights the other day, where I learned more about this topic and safelists and simple requests and redirects. perma-id/w3id.org#4185 and perma-id/w3id.org#4196. I tried a simple fetch from a browser console, and it does appear to do the above behavior. No profile will skip preflight, adding profile with URL will do one, then send the request. You do need a server setup to handle CORS headers, but then it works. await fetch(
"https://example.com/test",
{headers: {"Accept": "application/ld+json;profile=http://www.w3.org/ns/json-ld#expanded"}}
) |
This was discussed during the json-ld meeting on 13 November 2024. View the transcriptIssue Discussionbigbluehat: We're working through the project list. gkellogg: added issues that are class 1-3. subtopic w3c/json-ld-syntax#436 <gb> Issue 436 URI in Profile triggers CORS Unsafe Request Header Byte rule (by azaroth42) [spec:w3c] [needs discussion] [tag-needs-resolution] gkellogg: might just create "tokens" for profile paraemters. gkellogg: tokens not being namespaced is mitigated by the fact that the media-type is the namespace. bigbluehat: So, it treats the media-type as the namespace. gkellogg: not sure how we update guidance for using profile parameters. bigbluehat: This would be a breaking change for web annotations. niklasl: dlehn's reply may mean this isn't as horrible as it seems. pchampin: This doesn't seem to be a problem where things can't work, but making them work is tricky, due to pre-flight requests. <bigbluehat> q| pchampin: This is difficult to configure and easily forgotten. <gb> Issue 436 URI in Profile triggers CORS Unsafe Request Header Byte rule (by azaroth42) [spec:w3c] [needs discussion] [tag-needs-resolution] bigbluehat: There were some suggestions for defining enumerated values (tokens). <pchampin> I think it wouldn't hurt to define "short names" for the profiles in addition to the currently defined IRIs bigbluehat: The key is to not make it a breaking change. niklasl: Aren't link headers defined similarly, where there are pre-defined tokens and IRIs may also be used. bigbluehat: Browsers have made decisions which are affecting what we can do. <bigbluehat> > When processing the "profile" media type parameter, it is important to note that its value contains one or more URIs and not IRIs. In some cases it might therefore be necessary to convert between IRIs and URIs as specified in section 3 Relationship between IRIs and URIs of [RFC3987]. https://www.w3.org/TR/json-ld11/#iana-considerations <niklasl> application/ld+json;profile="http://iiif.io/api/presentation/3/context.json" niklasl: I think it would be good to add tokens. Rob's specific problem are more about the other uses of profiles. bigbluehat: The ramifications of this are not just expand/compact/... Rob's point is for other specifications that used the same pattern. <niklasl> See also: https://www.w3.org/TR/dx-prof-conneg/ (and https://profilenegotiation.github.io/I-D-Profile-Negotiation/I-D-Profile-Negotiation.html ) bigbluehat: There's reason to document this in the best-practices document. How this affects other specs would mean that they cannot treat profile as being extensible, and will need a new media type. gkellogg: we might create a registry to allow other specifications to add their profile parameters without needing a new media-type. bigbluehat: niklasl shared a document on using the profile parameter for content negotiation. pchampin: Reaching out the that TAG would be a good idea, as other specs rely on this, and they would be impacted. <niklasl> From the dx-prof-conneg draft: During 2018, DXWG members had a longer discussion with the JSON-LD WG at the annual forum TPAC in Lyon, France and it was concluded that the "profile” parameter in the Accept and Content-Type headers should be seen to convey profiles that are specific to the Media Type [such as JSON-LD's expanded .... ] pchampin: But, is there enough interest in IETF to continue the work? niklasl: There are aspects of the draft that goes into the profile parameter of the media type is the right way to go. <pchampin> https://www.w3.org/TR/vc-data-model-2.0/#media-type-precision pchampin: Regarding the value of using JSON-LD media-type with parameter vs a new media-type, VC has had to rely on this for a while. <niklasl> +1 to mentioning that "third" point of view (very pertinent IMHO) bigbluehat: I think we need to move on and come back to this issue. <bigbluehat> w3c/json-ld-syntax#443 <gb> Issue 443 `@protected` creates unresolvable conflicts when the same term is defined in two contexts top-level (by trwnh) [spec:editorial] [wr:commenter-agreed-partial] [class-2] |
Thanks for discussing it! I think we can close this particular issue -- the pre-flight does indeed solve the issue, and implementation notes in various specs in future versions could head it off completely. That said, at a conference in Amsterdam this week there were at least 6 organizations wanting a solution for profile negotiation for non JSON-LD serializations where the (The Perhaps there's sufficient convergence to at least have a call or two? |
In the IANA registration [1], we define a media type parameter called 'profile'. Its value is a space separated list of URIs, for which we registered six initial values. These can be composed together, and new values can be added for other "constraints or conventions".
The IIIF specifications use this functionality, for example to define the specific structure of the response in an API [2] as part of the media type. Similarly in Linked Art, we do the same [3].
However, in the WHATWG specification for fetch [4], it says that the value for the Accept header is NOT CORS safe, if it has more than 128 bytes (which multiple URIs might easily cause) or (more importantly) if the value contains an unsafe header byte. The unsafe header bytes include the character ":" ... which prevents any URI or CURIE with a namespace prefix separate by : from being CORS safe.
This means that we cannot use the JSON-LD media type as registered for content negotiation via the
accept
header according to the fetch specification, which was much of the rationale for the profile parameter.To resolve this, either WHATWG would need to change fetch, or W3C/IANA would need to change the definition of the media type and give some registration function for possible
profile
values, then all downstream specifications would need to register a safe profile value to use.I've added the tag-needs-resolution label, as I think that's the level this would need to run up to :(
[1] https://www.w3.org/TR/json-ld11/#iana-considerations
[2] https://iiif.io/api/presentation/3.0/#63-responses
[3] https://linked.art/api/1.0/json-ld/#introduction
[4] https://fetch.spec.whatwg.org/#ref-for-cors-unsafe-request-header-byte
The text was updated successfully, but these errors were encountered: