jpskill.com
🛠️ 開発・MCP コミュニティ

api-authentication

Implement secure API authentication with JWT, OAuth 2.0, API keys, and session management. Use when securing APIs, managing tokens, or implementing user authentication flows.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o api-authentication.zip https://jpskill.com/download/21323.zip && unzip -o api-authentication.zip && rm api-authentication.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/21323.zip -OutFile "$d\api-authentication.zip"; Expand-Archive "$d\api-authentication.zip" -DestinationPath $d -Force; ri "$d\api-authentication.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して api-authentication.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → api-authentication フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
6

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

API認証

目次

概要

JWTトークン、OAuth 2.0、APIキー、セッション管理など、適切なセキュリティプラクティスを用いたAPIの包括的な認証戦略を実装します。

使用場面

  • APIエンドポイントの保護
  • ユーザーのログイン/ログアウトフローの実装
  • アクセストークンとリフレッシュトークンの管理
  • OAuth 2.0プロバイダーとの連携
  • 機密データの保護
  • APIキー認証の実装

クイックスタート

最小限の動作例:

// Node.js JWT Implementation
const express = require('express');
const jwt = require('jsonwebtoken');
const bcrypt = require('bcrypt');

const app = express();
const SECRET_KEY = process.env.JWT_SECRET || 'your-secret-key';
const REFRESH_SECRET = process.env.REFRESH_SECRET || 'your-refresh-secret';

// User login endpoint
app.post('/api/auth/login', async (req, res) => {
  try {
    const { email, password } = req.body;

    // Find user in database
    const user = await User.findOne({ email });
    if (!user) {
      return res.status(401).json({ error: 'Invalid credentials' });
    }

    // Verify password
    const isValid = await bcrypt.compare(password, user.password);
    if (!isValid) {
      return res.status(401).json({ error: 'Invalid credentials' });
    }
// ... (see reference guides for full implementation)

リファレンスガイド

references/ディレクトリにある詳細な実装:

ガイド 内容
JWT Authentication JWT認証
OAuth 2.0 Implementation OAuth 2.0実装
API Key Authentication APIキー認証
Python Authentication Implementation Python認証実装

ベストプラクティス

✅ 実施すべきこと

  • すべての認証にHTTPSを使用する
  • トークンを安全に保存する(HttpOnlyクッキー)
  • トークンリフレッシュメカニズムを実装する
  • 適切なトークン有効期限を設定する
  • パスワードをハッシュ化し、ソルトを使用する
  • 強力な秘密鍵を使用する
  • すべてのリクエストでトークンを検証する
  • 認証エンドポイントにレート制限を実装する
  • 認証試行をログに記録する
  • シークレットを定期的にローテーションする

❌ 実施すべきでないこと

  • パスワードを平文で保存する
  • URLパラメータでトークンを送信する
  • 弱い秘密鍵を使用する
  • JWTペイロードに機密データを保存する
  • トークンの有効期限を無視する
  • 本番環境でHTTPSを無効にする
  • 機密トークンをログに記録する
  • 複数のサービスでAPIキーを再利用する
  • 資格情報をコードに保存する
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

API Authentication

Table of Contents

Overview

Implement comprehensive authentication strategies for APIs including JWT tokens, OAuth 2.0, API keys, and session management with proper security practices.

When to Use

  • Securing API endpoints
  • Implementing user login/logout flows
  • Managing access tokens and refresh tokens
  • Integrating OAuth 2.0 providers
  • Protecting sensitive data
  • Implementing API key authentication

Quick Start

Minimal working example:

// Node.js JWT Implementation
const express = require('express');
const jwt = require('jsonwebtoken');
const bcrypt = require('bcrypt');

const app = express();
const SECRET_KEY = process.env.JWT_SECRET || 'your-secret-key';
const REFRESH_SECRET = process.env.REFRESH_SECRET || 'your-refresh-secret';

// User login endpoint
app.post('/api/auth/login', async (req, res) => {
  try {
    const { email, password } = req.body;

    // Find user in database
    const user = await User.findOne({ email });
    if (!user) {
      return res.status(401).json({ error: 'Invalid credentials' });
    }

    // Verify password
    const isValid = await bcrypt.compare(password, user.password);
    if (!isValid) {
      return res.status(401).json({ error: 'Invalid credentials' });
    }
// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

Guide Contents
JWT Authentication JWT Authentication
OAuth 2.0 Implementation OAuth 2.0 Implementation
API Key Authentication API Key Authentication
Python Authentication Implementation Python Authentication Implementation

Best Practices

✅ DO

  • Use HTTPS for all authentication
  • Store tokens securely (HttpOnly cookies)
  • Implement token refresh mechanism
  • Set appropriate token expiration times
  • Hash and salt passwords
  • Use strong secret keys
  • Validate tokens on every request
  • Implement rate limiting on auth endpoints
  • Log authentication attempts
  • Rotate secrets regularly

❌ DON'T

  • Store passwords in plain text
  • Send tokens in URL parameters
  • Use weak secret keys
  • Store sensitive data in JWT payload
  • Ignore token expiration
  • Disable HTTPS in production
  • Log sensitive tokens
  • Reuse API keys across services
  • Store credentials in code

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。