]> git.ipfire.org Git - thirdparty/elfutils.git/commit
debuginfod: in --cors mode, add CORS response headers and OPTIONS method
authorHenning Meyer <hmeyer.eu@gmail.com>
Sat, 7 Dec 2024 20:01:54 +0000 (15:01 -0500)
committerFrank Ch. Eigler <fche@redhat.com>
Sun, 8 Dec 2024 21:01:05 +0000 (16:01 -0500)
commit87e7f211aa30888f80448be97bc4177c676fef82
treecc7c656c94636845d2e4e5ca5a4ab10fb6907fb4
parent04ba163e813f6b88da850c658a03ac7b5f19f7ad
debuginfod: in --cors mode, add CORS response headers and OPTIONS method

CORS is the Cross-Origin-Resource-Sharing mechanism explained at
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS 1. by default
JavaScript code from Website A cannot request arbitrary resources from
website B, these are called cross-origin-requests 2. The browser
performs what is called a preflight check, this the OPTIONS method 3.
the response allows website B fine-grained control over what the web
browser should allow 4. Setting "Access-Control-Allow-Origin: *" tells
the web browser to allow all access, e.g. the same behavior you get with
curl or debuginfod-find The website mentions that the corresponding spec
has been changed, such that preflight requests are no longer necessary,
but in the browsers I use today (Firefox 132 and Chromium 131) they are
still necessary.

I have confirmed that I can use debuginfod with this patch from my web
application at https://core-explorer.github.io/cdx-type/

FChE simplified the code and added a few quick "curl -i | grep" tests
to confirm the new headers are there.

   * debuginfod/debuginfod.cxx (handle_options): New function.
   (handler_cb): Call it for OPTIONS.  Add ACAO header for all
   successful requests.
   (parse_opt): Parse --cors.
   * tests/run-debuginfod-federation-metrics.sh,
   tests/run-debuginfod-find-metadata.sh: Lightly test.
   * doc/debuginfod.8: Document --cors option, default off.

Signed-off-by: Henning Meyer <hmeyer.eu@gmail.com>
Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
NEWS
debuginfod/debuginfod.cxx
doc/debuginfod.8
tests/run-debuginfod-federation-metrics.sh
tests/run-debuginfod-find-metadata.sh