Add origin matching with wildcard subdomains for the upcoming allowedOrigins option
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
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.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 13
- Forks
- 7
- Ø Merge
- 3 Std. 41 Min.
- Gemergte PRs (30 T.)
- 155
Entwicklungsumgebung
- Kein Dockerfile und keine 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 codercops/chatcops
-
Document the pre-chat formEvtl. vergeben @masyarakatai hat das vor 5 Tagen übernommen. Offendocumentation good first issue hacktoberfest widget
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
codercops/chatcops#70 · 5 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
docs: update the providers page for openai-compatible, registerProvider and provider importsEvtl. vergeben @prakashNalla hat das heute übernommen. Offendocumentation good first issue hacktoberfest website
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 76/100
codercops/chatcops#291 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
docs: add a protocol reference page for custom clientsEvtl. vergeben @kachamsiddarth hat das heute übernommen. Offendocumentation good first issue hacktoberfest website
codercops/chatcops#286 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Create @chatcops/store-cloudflare (D1, KV and a Durable Object counter)Evtl. vergeben @bhushan4work hat das heute übernommen. Offenenhancement hacktoberfest help wanted server
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
codercops/chatcops#249 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Create @chatcops/store-sqlite, a store for single-server setupsEvtl. vergeben @srikar-naidu hat das heute übernommen. Offenenhancement hacktoberfest help wanted server
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
codercops/chatcops#247 · 3 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in codercops/chatcops
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
phivk/rubiks-lab#33 ·
Maintainer antworten meist innerhalb von 1 Tag
-
BUG:Edit Album strips spaces from the password so albums with a leading/trailing space in the password can't be editedEvtl. vergeben @ManyaJain111 hat das heute übernommen. Offenbug enhancement possible-duplicate
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
AOSSIE-Org/PictoPy#1637 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
chaitin/MonkeyCode#1437 ·
Maintainer antworten meist innerhalb von 1 Tag
-
rtdb-info-connected-order test: unhandled 'connection is closed' rejection fails the CLI suiteOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
area:cards enhancement migration ready-for-agent
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
fil-donadoni/tolaria#6309 ·
Maintainer antworten meist innerhalb von 1 Tag