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

Bearer authentication rejects every token: jwt-decode v4 has no default export

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

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

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

評価

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

調査の方向性

app/lib/authn-bearer.js の jwt-decode の import と、155〜157 行付近の呼び出しから始め、その後 npx mocha --exit app/tests/authn/challenge-apikey-service.spec.js を実行します。発行されたトークンによるセッションリクエストが成功し、無効なトークンが引き続き 401 を返し、8 件すべての認証 spec がパスすれば完了です。現在マスクされている認証エラーについてカバレッジを追加する場合は、package.json と app/tests/run-mocha-separate-jobs.sh を確認してください。

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

説明

app/lib/authn-bearer.js:5 loads jwt-decode as const jwtDecoder = require('jwt-decode');, but package.json pins ^4.0.0 and v4 has no default export: require('jwt-decode') returns { InvalidTokenError, jwtDecode }. The call at :155 throws a TypeError, the catch at :156-157 passes it to done(null, false, err), and every Bearer request is rejected, including the token the API issues itself through the apikey challenge. Confirmed on main (6e6bf51); the same line and pin are on next (a69abef).

Run on main with Node 22, npx mocha --exit app/tests/authn/challenge-apikey-service.spec.js:

  • as shipped: 7 passing, 1 failing, GET /api/session returns the session: expected 200, got 401.
  • import changed to const { jwtDecode: jwtDecoder } = require('jwt-decode');: still 7/1, but now returns not authorized with an invalid token gets 500 instead of 401, because the catch forwards the InvalidTokenError object.
  • import change plus } catch { return done(null, false, { message: 'Invalid token' }); }: 8 passing.

OIDC client-credentials tokens go through the same call at :155 before the alg branch. I read that path; I did not run it, since I have no IdP here.

CI doesn't see this. npm test (package.json:29) does not include test:authn, and CI runs npm run coverage:cobertura (.github/workflows/ci.yml:74), which is c8 … npm test. npm run test:authn also exits 0 when specs fail: app/tests/run-mocha-separate-jobs.sh:3 uses find … -exec npx mocha {} \;, and find ignores the command's exit status (find . -maxdepth 0 -exec false \; exits 0; with {} + it exits 1). At HEAD it reported 6 failing specs and exited 0. Some of those need a local Keycloak, so running it in CI would need its own setup.

Happy to open the PR with the two-line fix against main, or next if you prefer. CONTRIBUTING points at develop, which I couldn't find.

主要言語
JavaScript
スター
56
フォーク
18
平均マージ
21時間 14分
マージ済み PR(30日)
10

環境構築

はじめの一歩

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

mitre-attack/attack-workbench-rest-api のほかの issue

mitre-attack/attack-workbench-rest-api の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

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

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