Customize access-control-allow-origin headers in order to set specific origin domains
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
Hướng nghiên cứu
Bắt đầu bằng cách theo dõi cách tùy chọn --cors được phân tích và nơi header phản hồi access-control-allow-origin được thiết lập. Xem lại hành vi CORS hiện có và tài liệu của nó trước khi quyết định cách biểu diễn các origin có thể cấu hình. Hoàn thành có nghĩa là cho phép các domain cụ thể hoặc * đồng thời duy trì hành vi đúng đối với các request có thông tin xác thực.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- JavaScript
- Star
- 14.2k
- Fork
- 1.6k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của http-party/http-server
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
http-party/http-server#982 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
http-party/http-server#977 · 2 reaction ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 8/100
http-party/http-server#980 · 2 bình luận ·
-
New chetĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
http-party/http-server#976 ·
-
Dreams local boyĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
http-party/http-server#975 ·
Tất cả issue của http-party/http-server
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
microsoft/TypeScript#65370 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue priority: medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
TMHSDigital/Free-Game-Dev-Assets#272 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
metrics priority: medium
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
LearningCircuit/local-deep-research#8336 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ace bug yaml
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
svelte: whitespace-only edit leaves an empty todo, edits not trimmed, filter not restored on reloadĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100