Add origin matching with wildcard subdomains for the upcoming allowedOrigins option
Les mainteneurs répondent en général sous 1 jour
Évaluation
Cette issue n'a pas encore été évaluée.
Description
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.
- Langage dominant
- TypeScript
- Étoiles
- 13
- Forks
- 7
- Merge moyen
- 3 h 28 min
- PR mergées (30 j)
- 182
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de codercops/chatcops
-
Type-check the TypeScript samples in the docsPeut-être pris @An16og l’a pris il y a 3 jours. Ouvertedocumentation hacktoberfest help wanted testing
Difficulté 4/5 3-5 jours Accessibilité débutants 70/100
codercops/chatcops#201 · 7 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
Hacktoberfest 2026: start hereOuvertehacktoberfest
Difficulté 1/5 Moins d'une heure Accessibilité débutants 35/100
Les mainteneurs répondent en général sous 1 jour
-
Add built-in translations to the widgetPeut-être pris @piyusshhjangid l’a pris il y a 2 jours. Ouvertehelp wanted widget
Difficulté 4/5 3-5 jours Accessibilité débutants 52/100
codercops/chatcops#55 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de codercops/chatcops
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
awesome-dsh-plugin/awesome-dsh-plugin#9184 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
farion1231/cc-switch#8829 ·
Les mainteneurs répondent en général sous 1 jour
-
[core-client] Remove unused hand-maintained transport helpers after the definition-table cutoverOuvertedoc-audit enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100