Add origin matching with wildcard subdomains for the upcoming allowedOrigins option
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Today the server takes one cors string (packages/server/src/config.ts, line 20) and sends it back in Access-Control-Allow-Origin on every response. A site with a staging domain or several subdomains can't list them, and '*' lets any site embed your bot. The next release adds allowedOrigins: string[]. This issue is the matching logic, as pure functions in a new file; wiring it into the adapters comes later.
What to do
Create packages/server/src/security/origin.ts with:
/** Returns the allowed entry that matches, or null. */
export function matchOrigin(origin: string | null, allowed: string[]): string | null;
/** CORS headers for a response to `origin`. */
export function corsHeaders(origin: string | null, allowed: string[]): Record<string, string>;
Rules for matchOrigin:
'*'in the list matches any origin, including a missing one.- An exact entry like
https://acme.commatches only that origin: same scheme, host and port.https://acme.com:8443is a different origin. https://*.acme.commatcheshttps://app.acme.comandhttps://a.b.acme.com, but nothttps://acme.comitself,http://app.acme.com, orhttps://evilacme.com.- Compare case-insensitively and ignore a trailing slash in the config entry. The
Originheader never has a path. null, an empty string, or the literal string"null"(sandboxed iframes send it) match only'*'.
corsHeaders returns:
Access-Control-Allow-Origin: *when the match is'*', the request's origin when an entry matched, and no allow-origin header when nothing matched- always
Vary: Origin, unless the list is just['*'], so caches don't serve one site's answer to another
Where to look
packages/server/src/adapters/vercel.ts, lines 6 to 16, for how CORS headers are set today- The MDN page on Origin for the exact format
Acceptance criteria
- New
packages/server/src/security/origin.tsandpackages/server/tests/security/origin.test.ts - A test for every rule above, including the
evilacme.com, port andhttpcases - Not exported from
@chatcops/serveryet, and no changeset needed (pnpm changeset --empty) -
pnpm test:coverageandpnpm lintpass
Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #<this issue number>. Setup notes (pnpm, build before test) are in CONTRIBUTING.md.
- Ngôn ngữ chính
- TypeScript
- Star
- 13
- Fork
- 7
- Merge trung bình
- 4 giờ 11 phút
- Pull request đã merge (30 ngày)
- 122
Chuẩn bị môi trường
- Không có Dockerfile hay 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 codercops/chatcops
-
enhancement hacktoberfest help wanted server
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Document the pre-chat formCó thể đã có người làm @masyarakatai đã nhận 4 ngày trước. Đang mởdocumentation good first issue hacktoberfest widget
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
codercops/chatcops#70 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement hacktoberfest help wanted server
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Create @chatcops/store-redis for Upstash and other Redis clientsCó thể đã có người làm @bhushan4work đã nhận hôm nay. Đang mởenhancement hacktoberfest help wanted server
codercops/chatcops#248 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement hacktoberfest help wanted server
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của codercops/chatcops
Issue tương tự
-
Area/Cloud Needs Triage Type/Bug
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
wso2/product-integrator#2847 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
bluesky-social/social-app#12118 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
heygen-com/hyperframes#6021 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Edit: Tele Posadas HDĐang mởcheck:passed streams:edit
Độ 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