Require a bearer token for the Express analytics endpoint
Mantenedores costumam responder em até 1 dia
Avaliação
Esta issue ainda não foi avaliada.
Descrição
chatcopsAnalyticsHandler (packages/server/src/adapters/express.ts, lines 73 to 78) answers anyone who finds the URL. The stats aren't secret, but they show how much traffic and how many leads a site gets, which is nobody else's business.
What to do
- Add
analyticsToken?: stringtoChatCopsServerConfig(packages/server/src/config.ts), with a short doc comment. - When it's set,
chatcopsAnalyticsHandleronly answers requests withAuthorization: Bearer <token>. Anything else gets401with{ "error": "unauthorized" }and aWWW-Authenticate: Bearerheader. - Compare the tokens in constant time. Don't import
node:crypto: this file is part of the same bundle Workers load. A small loop that compares every character, and checks the length, is enough. - When it isn't set, keep today's behavior so nothing breaks, but log one warning the first time the endpoint is hit, saying anyone can read the stats and how to set
analyticsToken. - Update the "Reading Stats with Express" section of
website/src/content/docs/core/analytics.mdx(line 18) with the option and acurlexample.
Where to look
packages/server/src/adapters/express.ts,chatcopsAnalyticsHandlerpackages/server/tests/adapters/express.test.ts, line 322, has the existing analytics test
Acceptance criteria
- With
analyticsTokenset: the right token gets the stats, while a missing token, a wrong token and a token of a different length get 401 - Without it: the stats are returned as today, and the warning is logged once across several requests
- Docs updated
- Changeset for
@chatcops/server(minor, since it adds an option) -
pnpm test:coverageandpnpm lintpass
Please get this merged by Oct 31.
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.
- Linguagem predominante
- TypeScript
- Estrelas
- 13
- Forks
- 7
- Merge médio
- 3h 41min
- PRs com merge (30d)
- 155
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de codercops/chatcops
-
Document the pre-chat formTalvez já em andamento @masyarakatai assumiu há 5 dias. Abertadocumentation good first issue hacktoberfest widget
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
codercops/chatcops#70 · 5 comentários ·
Mantenedores costumam responder em até 1 dia
-
docs: update the providers page for openai-compatible, registerProvider and provider importsTalvez já em andamento @prakashNalla assumiu hoje. Abertadocumentation good first issue hacktoberfest website
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 76/100
codercops/chatcops#291 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
docs: add a protocol reference page for custom clientsTalvez já em andamento @kachamsiddarth assumiu hoje. Abertadocumentation good first issue hacktoberfest website
codercops/chatcops#286 · 2 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Create @chatcops/store-cloudflare (D1, KV and a Durable Object counter)Talvez já em andamento @bhushan4work assumiu hoje. Abertaenhancement hacktoberfest help wanted server
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
codercops/chatcops#249 · 2 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Create @chatcops/store-sqlite, a store for single-server setupsTalvez já em andamento @srikar-naidu assumiu hoje. Abertaenhancement hacktoberfest help wanted server
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
codercops/chatcops#247 · 3 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de codercops/chatcops
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
phivk/rubiks-lab#33 ·
Mantenedores costumam responder em até 1 dia
-
BUG:Edit Album strips spaces from the password so albums with a leading/trailing space in the password can't be editedTalvez já em andamento @ManyaJain111 assumiu hoje. Abertabug enhancement possible-duplicate
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
AOSSIE-Org/PictoPy#1637 · 4 comentários ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
chaitin/MonkeyCode#1437 ·
Mantenedores costumam responder em até 1 dia
-
rtdb-info-connected-order test: unhandled 'connection is closed' rejection fails the CLI suiteAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
area:cards enhancement migration ready-for-agent
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
fil-donadoni/tolaria#6309 ·
Mantenedores costumam responder em até 1 dia