Delete the dead `verifyAccess()` JWT verifier in auth/index.js

オープン 初心者向け
#323 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
88/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, node.js

調査の方向性

auth/index.js から始めてください。verifyAccess を :143-150 で読み、その JSDoc を :137-142 で確認し、次に他の出現が default export 内の :186 のエントリだけであることを確かめてください。git grep -n "verifyAccess" を変更前と変更後に実行し、routes/client.js が auth.checkJwt を使用していることを確認して、呼び出し箇所を見落とさないようにしてください。完了条件は、grep が何も返さず、checkJwt が :44 にありトークンハンドラーが変更されておらず、npm run runtest -- auth/__tests__/token.test.js と __tests__/routes_mounted.test.js の両方が通ることです。

索引モデルが issue の本文から書いたものです。

説明

enhancement ready-for-agent

This was generated by AI during triage.

Filed from the Section 5 pass. Ruling already given: delete it. Workstream 1 (centralized auth). Small, self-contained, and it removes a second trust anchor that a future reader could mistake for the live one.

Problem

verifyAccess() is dead code, and it is dead code that looks like the authoritative JWT verifier.

  • Defined at auth/index.js:143-150 with a JSDoc block above it at :137-142 (the block opens with /** Required for API Key Access, which reads like a supported access path).
  • Re-exported on the default export object at auth/index.js:186 (inside export default { … } at :182-190), so it is importable from anywhere.
  • Zero call sites. Re-verified on the live default branch (5c32e5d): the only occurrences of the string verifyAccess anywhere in the repository are its own definition at :143 and its own export at :186. Nothing in routes/, controllers/, app.js, bin/, or any test references it, and nothing imports it from the default export.

Why leaving it is worse than ordinary dead code: it hardcodes a second, different trust anchor, with its own secret, issuer: https://rerum.io/, and audience: http://rerum.io/api (:145-147).

Meanwhile the live verification path is checkJwt at auth/index.js:44 — [READONLY, auth(), _tokenError, _extractUser] — and auth() is called with no arguments at all. Verified: auth/index.js:44 is the only auth( call site in the repo, and ISSUER_BASE_URL appears only in documentation (README.md:88, CONTRIBUTING.md:46, .github/copilot-instructions.md:49), never in a process.env lookup. So there is exactly one documented tenant variable, it is unused, and the only place in the codebase that spells out an issuer and audience is this unreachable function.

The drift risk is therefore already realised rather than hypothetical: anyone auditing "what issuer does RERUM accept?" finds verifyAccess and concludes https://rerum.io/, which is not what the live middleware does. It is also not callable as written — jwt is never bound in this module (:1 imports only { auth } from express-oauth2-jwt-bearer, and the only other jwt matches in the file are inside the package name and in the JSDoc prose), so a call to verifyAccess() would throw ReferenceError: jwt is not defined. That is a further argument for deletion, and a reason not to spend effort on "fixing" it.

Desired behavior

  1. Delete verifyAccess at auth/index.js:143-150 and its JSDoc block at :137-142 — removing only the function body would leave a dangling comment that still advertises the feature.
  2. Delete the verifyAccess, entry from the default export object at auth/index.js:186. Leave the rest of that object (checkJwt, generateNewAccessToken, generateNewRefreshToken, _tokenError, _extractUser, isGenerator) exactly as it is; isBot is deliberately exported at :187 and has a real consumer.
  3. Change no verification behaviour. The live chain at :44 and the token handlers at :52 and :97 are untouched by this ticket. If the real finding is "the verifier should be configured from ISSUER_BASE_URL", that belongs to #164, which owns the hardcoded-tenant problem and already carries an Auth0-side blocker.

Do not change

  • checkJwt (auth/index.js:44) and its order: READONLY must stay first so a read-only instance short-circuits before token parsing, READONLY (:173-180) answers 503 before auth() ever sees the request.
  • _tokenError (:3-23) and the bot path it depends on — isBot() at :168-171 and its fail-closed guard at :169. That code is covered by auth/__tests__/token.test.js:85, :96, :107 and is separately tracked by #178.
  • routes/client.js (:10, :13) — the verify route there uses auth.checkJwt, not verifyAccess; confirm this while deleting so no call site is missed.
  • Do not add an issuerBaseURL/audience option to auth() as part of this cleanup. It is a real gap, but it changes what tokens the public API accepts and is #164's decision.

Verification

  1. git grep -n "verifyAccess" returns no matches anywhere in the tree (previously 2).
  2. git grep -n "jwt(" auth/index.js returns no matches, confirming no half-removed call survives.
  3. npm run runtest -- auth/__tests__/token.test.js passes. Important: it reads the live chain by index — auth.checkJwt[2] at :131 and auth.checkJwt[3] at :166 — so those positions must still resolve to _tokenError and _extractUser.
  4. npm run runtest -- __tests__/routes_mounted.test.js passes (30s). It builds the whole app, so any surviving import of the removed name fails there.
  5. npm start prints LISTENING ON 3005 within ~3s, then curl -I http://localhost:3005/v1/API.html returns 200.
  6. Optional but worth one line in the PR: confirm the module still evaluates by calling a surviving export in a throwaway node -e import. The module runs client.connect() at import time (database/index.js via controllers), so this check needs the experimental-VM flag the repo's npm run runtest uses — if it turns into more work than the deletion, skip it; step 4 covers the same ground.
主要言語
JavaScript
スター
3
フォーク
7
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

CenterForDigitalHumanities/rerum_server_nodejs のほかの issue

CenterForDigitalHumanities/rerum_server_nodejs の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

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

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