スキル api-jwt-authenticator
📦

api-jwt-authenticator

v1.0.0 低リスク

JWT認証でFastAPI APIを安全に保護する

FastAPI APIには、エンドポイントとユーザーデータを保護するための安全な認証が必要です。このスキルは、JWTトークン検証、ユーザーアイデンティティ確認、REST API向けのロールベースアクセス制御の実装ガイダンスを提供します。

対応: Claude Codex Code(CC)
🥉 79 ブロンズ
1

スキルの ZIP をダウンロード

2

Claudeでアップロード

設定 → 機能 → スキル → スキルをアップロード に移動

3

オンにして使い始める

エージェントが読めるリソース

AI エージェント、クローラー、スクリプトがページ全体ではなく整理されたコンテキストを必要とする場合は、これらのリンクを使ってください。

テストする

「api-jwt-authenticator」を使用しています。 FastAPIのユーザープロファイルエンドポイントにJWT認証を追加する

期待される結果:

  • AuthorizationヘッダーからJWTトークンを抽出
  • 秘密鍵でトークン署名を検証
  • トークン有効期限を検証(期限切れでない)
  • トークンペイロードからユーザーIDを抽出
  • 認証済みリクエストにユーザープロファイルを返す
  • 無効なトークンには401 Unauthorizedを返す

「api-jwt-authenticator」を使用しています。 ロールベースアクセスを使った管理者専用エンドポイントを作成する

期待される結果:

  • JWTトークンペイロードからユーザーロールを抽出
  • 必要な「admin」権限とロールを比較
  • 管理者ユーザーに機密エンドポイントへのアクセスを許可
  • 管理者以外のユーザーには403 Forbiddenを返す
  • セキュリティ監視のために認証監査を記録

セキュリティ監査

低リスク
v6 • 6/28/2026

Static analysis flagged Markdown backticks, JWT terminology, and HTTP authentication documentation as suspicious patterns. Review found no executable code, shell invocation, prompt injection, malware behavior, or data exfiltration in SKILL.md. The skill is a conceptual security guide and is safe to publish with low residual risk.

1
スキャンされたファイル
136
解析済み行数
0
Review items
3
False positives ignored
Static false positives ignored (3)

These static matches were dismissed by semantic review or matched schema-only tokens, so they are shown for transparency but do not drive the quality score.

False Positive: Markdown Formatting Flagged as Shell Execution
The flagged locations use Markdown inline code for an Authorization header and JWT claim names. They do not contain Ruby code, shell execution, command substitution, or user-controlled command construction.
The evidence is plain Markdown documentation. The surrounding text describes token format and claims, not executable Ruby or shell behavior.
False Positive: Weak Cryptography Pattern Not Confirmed
The flagged lines do not specify a weak signing algorithm or unsafe cryptographic implementation. Line 7 is the skill description, and line 128 discusses testing error response formats.
No cryptographic algorithm is named at either location. The skill recommends validating JWT signatures and expiration but does not prescribe insecure crypto.
False Positive: System Reconnaissance Pattern Not Confirmed
The flagged locations describe HTTP status handling, token structure, information disclosure avoidance, and authentication tests. They do not collect host data, enumerate files, or inspect the runtime environment.
The context is API authentication guidance. No commands, filesystem reads, environment probing, or network discovery instructions are present.
セキュリティ問題は見つかりませんでした
監査者: codex 監査履歴を表示 →

品質スコア

55
アーキテクチャ
100
保守性
87
コンテンツ
70
コミュニティ
95
セキュリティ
83
仕様準拠

作成できるもの

APIエンドポイントの保護

JWTトークン検証とユーザーアイデンティティ確認により、認証済みユーザーアクセスが必要なFastAPIエンドポイントを保護します。

アクセス制御の実装

ロールベースアクセス制御ポリシーを適用し、ユーザーが権限のあるリソースのみを閲覧できるようにします。

認証システムの設計

適切なセキュリティ考慮のもと、JWTトークンを用いたマイクロサービス向けのステートレス認証パターンを設計します。

これらのプロンプトを試す

基本的なJWT保護
Use the API JWT Authenticator skill to add JWT authentication to a FastAPI endpoint. Extract the Bearer token from the Authorization header, validate the signature using a secret key, verify expiration, and return user info or 401 error.
ユーザー別アクセス
Apply the JWT Authenticator pattern to ensure users can only access their own resources. Extract user_id from token payload, compare with resource owner, and return 403 if they do not match.
ロールベース権限
Implement role-based access control using the JWT Authenticator skill. Define admin, moderator, and user roles in token claims. Create dependencies that verify user role before allowing endpoint access.
完全な認証システム
Design a complete JWT authentication system for FastAPI following best practices from the API JWT Authenticator skill. Include token generation endpoint, protected routes, error handling, and production security considerations.

ベストプラクティス

  • 本番環境では常にHTTPSを使用し、送信中のトークン盗聴を防ぐ
  • 秘密鍵は環境変数や安全なボールトに保存し、ソースコードに置かない
  • 侵害されたトークンの露出期間を制限するため、適切なトークン有効期限を設定する

回避

  • JWTトークンをURLやサーバーログにそのまま露出しない。トークン盗難につながるため
  • JWTペイロードに機密情報を保存しない。トークンは誰でもデコードできるため
  • 開発やテスト環境でもトークン署名検証を省略しない

よくある質問

このスキルで使えるPythonライブラリは何ですか?
JWTのエンコード/デコードにはpython-jose、パスワードハッシュにはpasslibを使用します。どちらもFastAPIの依存性と相性が良いです。
JWTトークンの有効期間はどのくらいが適切ですか?
アクセストークンはセキュリティ上、通常15〜30分で失効します。長時間セッションには適切なローテーション付きのリフレッシュトークンを使います。
マイクロサービスで使えますか?
はい。JWTはステートレスなマイクロサービスに最適です。サービス間で秘密鍵を共有するか、公開鍵暗号を使ってトークン検証を行います。
トークンのデータは暗号化されていますか?
JWTトークンは署名されているだけで暗号化はされません。誰でもペイロードをデコードできます。パスワードなどの機密データは絶対に含めないでください。
なぜトークン検証が失敗するのですか?
サーバーの時計が同期しているか確認し、秘密鍵が完全に一致しているか検証し、必要なクレームがトークンに含まれていることを確かめてください。
セッションベース認証と比べてどうですか?
JWTはステートレスでサービス間の水平スケールに向きます。セッションはサーバー側の保存が必要ですが即時失効が可能です。アーキテクチャ要件に合わせて選択してください。

開発者情報

ファイル構成

📄 SKILL.md