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時間 33分
- マージ済み PR(30日)
- 176
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
codercops/chatcops のほかの issue
-
Add startup checks that catch weak or leaked security settings対応中かも @varun-pahuja が 2 日前に担当しました。 オープンenhancement good first issue hacktoberfest server
codercops/chatcops#231 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Type-check the TypeScript samples in the docs対応中かも @An16og が 1 日前に担当しました。 オープンdocumentation hacktoberfest help wanted testing
難易度 4/5 3〜5日 初心者へのやさしさ 70/100
codercops/chatcops#201 · コメント 7 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
hacktoberfest
難易度 1/5 1時間未満 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
help wanted widget
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
codercops/chatcops#55 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
codercops/chatcops の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
logto-io/logto#9837 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
lingdojo/kana-dojo#32964 · コメント 1 件 · リアクション 5 件 ·
メンテナーはふだん 1 日以内に返信
-
Documentation status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
mastra-ai/mastra#28194 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
priority-low refactor-3
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 3 日以内に返信