Require a bearer token for the Express analytics endpoint
維護者通常 1 天內回覆
評估
這個 Issue 還沒有評估資料。
描述
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.
- 主要語言
- TypeScript
- 星號
- 13
- 分支
- 7
- 平均合併
- 3 小時 41 分鐘
- 30 天內合併 PR
- 155
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
codercops/chatcops 的其他 Issue
-
Document the pre-chat form可能已有人在做 @masyarakatai 於 5 天前認領。 未關閉documentation good first issue hacktoberfest widget
難度 2/5 1-3 小時 新手友好度 88/100
codercops/chatcops#70 · 5 則留言 ·
維護者通常 1 天內回覆
-
docs: update the providers page for openai-compatible, registerProvider and provider imports可能已有人在做 @prakashNalla 今天認領。 未關閉documentation good first issue hacktoberfest website
難度 3/5 1-2 天 新手友好度 76/100
codercops/chatcops#291 · 1 則留言 ·
維護者通常 1 天內回覆
-
docs: add a protocol reference page for custom clients可能已有人在做 @kachamsiddarth 今天認領。 未關閉documentation good first issue hacktoberfest website
codercops/chatcops#286 · 2 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
Create @chatcops/store-cloudflare (D1, KV and a Durable Object counter)可能已有人在做 @bhushan4work 今天認領。 未關閉enhancement hacktoberfest help wanted server
難度 5/5 一週以上 新手友好度 25/100
codercops/chatcops#249 · 2 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
Create @chatcops/store-sqlite, a store for single-server setups可能已有人在做 @srikar-naidu 今天認領。 未關閉enhancement hacktoberfest help wanted server
難度 5/5 一週以上 新手友好度 35/100
codercops/chatcops#247 · 3 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
查看 codercops/chatcops 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
phivk/rubiks-lab#33 ·
維護者通常 1 天內回覆
-
BUG:Edit Album strips spaces from the password so albums with a leading/trailing space in the password can't be edited可能已有人在做 @ManyaJain111 今天認領。 未關閉bug enhancement possible-duplicate
難度 2/5 1-3 小時 新手友好度 77/100
AOSSIE-Org/PictoPy#1637 · 4 則留言 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
chaitin/MonkeyCode#1437 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
area:cards enhancement migration ready-for-agent
難度 2/5 1-3 小時 新手友好度 70/100
fil-donadoni/tolaria#6309 ·
維護者通常 1 天內回覆