Add origin matching with wildcard subdomains for the upcoming allowedOrigins option
Los mantenedores suelen responder en 1 día
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 13
- Forks
- 7
- Merge medio
- 4 h 11 min
- PR fusionados (30 d)
- 122
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de codercops/chatcops
-
enhancement hacktoberfest help wanted server
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Document the pre-chat formPosiblemente ocupada @masyarakatai la tomó hace 4 días. Abiertodocumentation good first issue hacktoberfest widget
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
codercops/chatcops#70 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
enhancement hacktoberfest help wanted server
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Los mantenedores suelen responder en 1 día
-
Create @chatcops/store-redis for Upstash and other Redis clientsPosiblemente ocupada @bhushan4work la tomó hace 1 día. Abiertoenhancement hacktoberfest help wanted server
codercops/chatcops#248 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
enhancement hacktoberfest help wanted server
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
Todos los issues de codercops/chatcops
Issues similares
-
frontend
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
ranxianglei/billion-context#4172 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
awslabs/threat-composer#362 ·
Los mantenedores suelen responder en 1 día
-
Area/Cloud Needs Triage Type/Bug
Dificultad 1/5 1-3 horas Aptitud para principiantes 86/100
wso2/product-integrator#2847 ·
Los mantenedores suelen responder en 1 día