Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Require a bearer token for the Express analytics endpoint

クローズ
#232 コメント 2 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@anurag2787 がすでに取り組んでいます。

2026年10月20日 から。

  • #272 @anurag2787 による — マージ済み

評価

この issue はまだ評価されていません。

説明

enhancement good first issue hacktoberfest server

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?: string to ChatCopsServerConfig (packages/server/src/config.ts), with a short doc comment.
  • When it's set, chatcopsAnalyticsHandler only answers requests with Authorization: Bearer <token>. Anything else gets 401 with { "error": "unauthorized" } and a WWW-Authenticate: Bearer header.
  • 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 a curl example.

Where to look

  • packages/server/src/adapters/express.ts, chatcopsAnalyticsHandler
  • packages/server/tests/adapters/express.test.ts, line 322, has the existing analytics test

Acceptance criteria

  • With analyticsToken set: 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:coverage and pnpm lint pass

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分
マージ済み PR(30日)
155

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

codercops/chatcops のほかの issue

codercops/chatcops の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。