Skip to content

fix(#121): ApiKeyAuthMiddleware で TokenVerificationException を 401 に変換する#134

Merged
hideyukiMORI merged 1 commit into
mainfrom
fix/121-api-key-exception-handling
May 19, 2026
Merged

fix(#121): ApiKeyAuthMiddleware で TokenVerificationException を 401 に変換する#134
hideyukiMORI merged 1 commit into
mainfrom
fix/121-api-key-exception-handling

Conversation

@hideyukiMORI
Copy link
Copy Markdown
Owner

Summary

  • ApiKeyAuthMiddlewareTokenVerificationException をキャッチしておらず、BearerTokenMiddleware と非対称だった
  • try/except TokenVerificationException を追加し、例外時も 401 を返すよう修正
  • ExplodingVerifier を使ったテストで 500 → 401 の修正を検証

Test plan

  • 既存の 4 テストが継続パス
  • test_verifier_raises_token_verification_exception_returns_401 — verifier が例外を投げても 401(新規)

Closes #121

🤖 Generated with Claude Code

BearerTokenMiddleware と同様に try/except を追加し、verifier.verify() が
例外を投げた場合も 401 を返すよう修正する。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hideyukiMORI hideyukiMORI merged commit 41ea43d into main May 19, 2026
1 check passed
@hideyukiMORI hideyukiMORI deleted the fix/121-api-key-exception-handling branch May 21, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

X-Request-Id ヘッダーが未検証でログインジェクションが可能

1 participant