Communitygithub.com

認証セキュリティ

パスワードのbcrypt/argon2ハッシュ化、ブルートフォース対策、安全なパスワードリセットを提供する認証セキュリティスキル。

認証セキュリティ とは?

このスキルは、WebアプリケーションやAPIエンドポイントにおける認証セキュリティの実装を支援します。bcrypt(コストファクター12以上)またはargon2idを使用したパスワードハッシュ化、ログインエンドポイントへのレート制限(IP単位で毎分5回、アカウント単位で毎時10回)、指数関数的ロックアウト(10回失敗で15分間ハードロック)を提供します。パスワードリセットトークンは暗号学的にランダムで1回限り、1時間で期限切れとなります。エラーメッセージは「メールアドレスまたはパスワードが無効です」のような汎用的なものを返し、どちらのフィールドが間違っているかは明かしません。最低8文字のパスワード長を強制し、HaveIBeenPwned APIを使用して漏洩パスワードリストとの照合も行います。このスキールはTypeScript/JavaScript環境(Express、Next.jsなど)で利用でき、コードスニペット付きで即座に実装可能です。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/auth-security

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

認証セキュリティ は何をしますか?

ルール

  • パスワードはbcrypt(コストファクター12以上)またはargon2idでハッシュ化する — 平文やSHA/MD5で保存しない
  • ログインエンドポイントにレート制限をかける:IPごとに毎分最大5回、アカウントごとに毎時最大10回
  • 指数関数的ロックアウトを実装:失敗試行後に1秒、2秒、4秒、8秒...とロック時間を延長。10回失敗で15分間ハードロック
  • パスワードリセットトークン:暗号学的にランダム、1回限り有効、最大1時間で期限切れ
  • 汎用的なエラーを返す:「メールアドレスまたはパスワードが無効です」 — どちらのフィールドが間違っているかを決して明かさない
  • 最低8文字のパスワード長を強制し、漏洩パスワードリスト(HaveIBeenPwned API)と照合する
import bcrypt from "bcrypt";

// サインアップ時にハッシュ化
const hash = await bcrypt.hash(password, 12);

// ログイン時に検証
const valid = await bcrypt.compare(password, storedHash);
if (!valid) {
  await incrementFailedAttempts(userId);
  return res.status(401).json({ error: "Invalid email or password" });
}
await resetFailedAttempts(userId);
// ブルートフォースロックアウトチェック
async function checkLockout(userId: string) {
  const attempts = await getFailedAttempts(userId);
  if (attempts.count >= 10) {
    const lockoutEnd = attempts.lastAttempt + 15 * 60 * 1000;
    if (Date.now() < lockoutEnd) throw new Error("Account temporarily locked");
  }
}

避けるべきこと

  • パスワードを平文、base64、または可逆暗号化で保存すること
  • パスワードにSHA-256を使用すること — 高速であるためブルートフォースが可能
  • ログインやパスワードリセット時にメールアドレスの存在を明かすこと
  • 期限が切れない、または再利用可能なパスワードリセットリンク
  • 単一IPからの無制限のログイン試行を許可すること

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

YepAPI/skills

WCAG 2.1 AA — semantic HTML, keyboard navigation, screen readers.

YepAPI/skills

Experiment setup, variant splitting, statistical significance, and feature flag integration.

YepAPI/skills

CRUD generators, data tables, user management, role-based access, and bulk operations.

YepAPI/skills

Monitor what ChatGPT and Gemini say about your brand using YepAPI.

YepAPI/skills

Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

YepAPI/skills

Commander.js, interactive prompts with Clack, spinners, colors, config files, exit codes, and npm publishing.

YepAPI/skills

cmdk integration, Cmd+K trigger, fuzzy search, grouped actions, keyboard navigation, and dynamic action registration.

YepAPI/skills

Content planning with trend and sentiment data from YepAPI.

YepAPI/skills

Content calendar, keyword-driven planning, and content briefs.

YepAPI/skills

Theme switching with CSS variables, system preference detection, next-themes, and persistence.

YepAPI/skills

Threaded comments, @mentions, reactions, moderation queue, optimistic UI, and cursor pagination.

YepAPI/skills

Competitive analysis between domains using YepAPI.

YepAPI/skills

Layout grids, KPI cards, data tables with sorting/filtering, sidebar navigation, and responsive breakpoints.

YepAPI/skills

Data encryption — TLS everywhere, AES-256-GCM for PII, bcrypt passwords, encrypted backups.

YepAPI/skills

Chart patterns with Recharts/Nivo/D3, responsive containers, color scales, and accessibility.

YepAPI/skills

Drizzle schema definition, push vs migrate, type-safe queries, relations, transactions, and prepared statements.

YepAPI/skills

Upload handling, resize/compress, CDN delivery, blur placeholders, and next/image patterns.

YepAPI/skills

Local business and Google Maps research using YepAPI.

YepAPI/skills

Cursor-based pagination, IntersectionObserver, virtualized lists with @tanstack/react-virtual, and scroll position restoration.

YepAPI/skills

Chat UI components, streaming responses with AI SDK, context window management, and RAG patterns.

関連スキル