Customize access-control-allow-origin headers in order to set specific origin domains
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- javascript
Rechercherichtung
Beginne damit nachzuverfolgen, wie die Option --cors geparst wird und wo der access-control-allow-origin-Response-Header gesetzt wird. Überprüfe das bestehende CORS-Verhalten und die zugehörige Dokumentation, bevor du entscheidest, wie konfigurierbare Origins dargestellt werden sollen. Als erledigt gilt die Aufgabe, wenn bestimmte Domains oder * ermöglicht werden und dabei das korrekte Verhalten für Anfragen mit Credentials erhalten bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
What's the problem this feature will solve?
Currently, with --cors enabled access-control-allow-origin hard coded to *. If http-server is behind features that require authentication (client SSL certs in my case), the fetch spec requires browsers to validate that the requesting server be set as an allowed origin. So when server1 makes a request to server2 it fails because of the wildcard. This is the intended behavior as designed. Firefox currently (correctly) follows the fetch spec but, Chrome and Edge do not. At some point, chrome and edge 'should' eventually be fixed.
Chrome and Edge still send certs unprompted when executing the fetch command, but when fetch is set to {credentials:"include"} in server1 requesting information from server2 you now get this error:
Access to fetch at 'https://server2.tld' from origin 'https://server1.tld' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.
Describe the solution you'd like
Requesting the ability to customize access-control-allow-origin headers in order to pass specific domains or set * manually.
This will allow http-server to be used correctly with authentication when a fetch is set to { credentials:"include" } .
Alternative Solutions
When requesting server does not have fetch is set to { credentials:"include" }
- Firefox: in about:config set
network.cors_preflight.allow_client_certto true. Otherwise browser fails preflight because certs are not passed. - Chrome: in chrome://flags set
Omit TLS client certificates if credential mode disallowsto disabled. This is also the default behavior, chrome automatically sends credentials, this is against the spec. - Edge: no changes, flags are not available for this setting (default behavior, edge automatically sends credentials, this is against the spec.
When fetch is set to { credentials:"include" } on server1
Fails on all browsers
Access to fetch at 'https://server2.tld' from origin 'https://server1.tld' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.
Alternate hack
Modify http-server source locally to hard code for my specific use-case, replace access-control-allow-origin = '*' and hard code it to access-control-allow-origin = 'https://server1.tld so it works for me. then enable --cors, start http-server.
Additional context
I'm sure there are other use-cases for setting access-control-allow-origin to custom domains, but for the authentication issue with client SSL certs, it's a must have.
I am aware that solution #760 to issue #729 can potentially fix my problem, but automatically mirroring the origin server will allow any origin to pass credentials, which is not very safe. This fix should only be used for testing and not production.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 14.2k
- Forks
- 1.6k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus http-party/http-server
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
http-party/http-server#982 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
http-party/http-server#977 · 2 Reaktionen ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 8/100
http-party/http-server#980 · 2 Kommentare ·
-
New chetOffen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 10/100
http-party/http-server#976 ·
-
Dreams local boyOffen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 15/100
http-party/http-server#975 ·
Alle Issues in http-party/http-server
Ähnliche Issues
-
area:models enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
status: ready
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
melodic-software/claude-code-plugins#14389 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100