Add a typed, explicit CORS policy evaluator
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với contract bắt buộc và các phần CORS được liên kết của WHATWG Fetch Standard, sau đó tìm các kiểu request/response của Roc trong repository và thiết lập test với real-listener. Xác định ranh giới của policy và result trước khi triển khai. Được xem là hoàn tất khi các test với real-listener bao phủ các trường hợp thực tế và preflight, việc normalization, wildcard/credential, Vary, trạng thái disabled-by-default và các biến thể đã được cache.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Add a pure Cors module that evaluates actual and preflight requests against an immutable policy.
Illustrative flow:
match Cors.evaluate(policy, request) {
NotCors => handle(request)
Preflight(response) => Ok(Server.respond(response))
Rejected(response) => Ok(Server.respond(response))
Allowed(cors_headers) => {
response = handle(request)?
Ok(Server.respond(Cors.apply(cors_headers, response)?))
}
}
Why this belongs in the platform
CORS is widely supplied by web-framework middleware, including tower-http. Its header interactions are sufficiently subtle that applications should not independently reproduce them.
It should remain an explicit Roc request/response transformation. It does not require a new middleware runtime or host callback.
Required contract
- CORS is disabled unless an application constructs and invokes a policy.
- Exact serialized origins—scheme, host, and port—are the initial allowlist mechanism.
- Treat the special
nullorigin as denied unless explicitly allowed. - Validate requested methods and header names for preflight requests.
- Support configured exposed headers, credential permission, and bounded preflight max age.
- Reject policy construction that combines credentialed requests with wildcard origin.
- Dynamic origin responses merge
Vary: Origincase-insensitively without discarding existingVaryvalues. Access-Control-Allow-Credentialsmust serialize as lowercasetrue.- Preflight responses do not depend on receiving credentials; browsers do not attach credentials to the preflight itself.
- Malformed or conflicting
Originfields produce a deterministic denial. - The result distinguishes non-CORS, allowed actual, successful preflight, and rejected requests.
Documentation must emphasize that CORS is not CSRF protection. A "simple" cross-origin request can still perform a server-side action even when the browser refuses to expose its response.
Non-goals
- Regex or suffix origin matching in the first version
- Guessing trusted origins from
Hostor forwarded headers - CSRF protection
- Authentication or authorization
- Applying CORS automatically to native file or operational routes
- A generic middleware stack
Acceptance criteria
- Actual and preflight requests are handled from the same validated policy.
- Wildcard/credentials and
Varybehavior follow the Fetch Standard. - Origin, method, and header matching have explicit case and normalization rules.
- No CORS behavior is enabled by default.
- Real-listener tests cover allowed, denied, credentialed, and cached variants.
References
- Ngôn ngữ chính
- HTML
- Star
- 110
- Fork
- 25
- Merge trung bình
- 18 giờ 28 phút
- Pull request đã merge (30 ngày)
- 16
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không 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 roc-lang/basic-webserver
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
roc-lang/basic-webserver#277 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
roc-lang/basic-webserver#274 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
roc-lang/basic-webserver#273 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
roc-lang/basic-webserver#272 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
roc-lang/basic-webserver#265 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của roc-lang/basic-webserver
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
OHDSI/Data2Evidence#3815 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
e2e-failure ready-to-code
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
redhat-developer/rhdh-plugin-export-overlays#4995 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fidelity
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Azure SAS signing uses local time instead of UTC, shifting validity window on non-UTC hostsCó thể đã có người làm @huanghaoyuanhhy đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
zilliztech/milvus-backup#1418 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] download repeatedly fetches unchanged gzip responses due to compressed/decoded size mismatchCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
stanfordnlp/dspy#11000 ·
Maintainer thường phản hồi trong vòng 1 ngày