Add a typed, explicit CORS policy evaluator
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
先从所需的 contract 和链接的 WHATWG Fetch Standard CORS 章节开始,然后定位 repository 中的 Roc request/response 类型以及 real-listener 测试设置。在实现之前定义 policy 和 result 的边界。完成标准是:通过 real-listener 测试覆盖实际情况和 preflight 情况、normalization、wildcard/credential、Vary、disabled-by-default 以及缓存变体。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- HTML
- 星标
- 110
- 派生
- 25
- 平均合并
- 18 小时 28 分钟
- 30 天内合并 PR
- 16
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
roc-lang/basic-webserver 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 83/100
roc-lang/basic-webserver#277 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
roc-lang/basic-webserver#274 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 15/100
roc-lang/basic-webserver#273 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 15/100
roc-lang/basic-webserver#272 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 25/100
roc-lang/basic-webserver#265 ·
维护者通常 1 天内回复
查看 roc-lang/basic-webserver 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
OHDSI/Data2Evidence#3815 ·
维护者通常 3 天内回复
-
e2e-failure ready-to-code
难度 2/5 1-3 小时 新手友好度 78/100
redhat-developer/rhdh-plugin-export-overlays#4995 · 1 条评论 ·
维护者通常 1 天内回复
-
fidelity
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
[Bug]: Azure SAS signing uses local time instead of UTC, shifting validity window on non-UTC hosts可能已有人在做 @huanghaoyuanhhy 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
zilliztech/milvus-backup#1418 ·
维护者通常 1 天内回复
-
[Bug] download repeatedly fetches unchanged gzip responses due to compressed/decoded size mismatch可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
stanfordnlp/dspy#11000 ·
维护者通常 1 天内回复