Communitygithub.com

YepAPI/skills

身份驗證安全 — bcrypt/argon2 雜湊、暴力破解防護、安全的密碼重置。

skills 是什麼?

此技能專注於實施高強度的身份驗證安全措施,涵蓋密碼雜湊、速率限制、帳戶鎖定及密碼重置等關鍵環節。它要求開發者使用 bcrypt(成本因子 12 以上)或 argon2id 進行密碼雜湊,嚴禁明文儲存或使用 SHA/MD5 等快速演算法。同時,針對登入端點實施嚴格的速率限制(每 IP 每分鐘 5 次、每個帳號每小時 10 次),並採用指數級增長的鎖定策略,最終在 10 次失敗後硬鎖 15 分鐘。此外,密碼重置令牌需具備加密隨機性、一次性使用且 1 小時內過期,並要求回傳通用錯誤訊息(如「電子郵件或密碼無效」),避免洩露具體哪個欄位錯誤。支援 Node.js 平台,並可整合 HaveIBeenPwned API 檢查密碼是否外洩。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/auth-security

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

身份驗證安全

規則

  • 使用 bcrypt(成本因子 12 以上)或 argon2id 對密碼進行雜湊處理 — 絕不安放明文密碼或使用 SHA/MD5
  • 對登入端點實施速率限制:每個 IP 每分鐘最多 5 次嘗試,每個帳號每小時最多 10 次
  • 實施指數級鎖定:失敗後依序鎖定 1 秒、2 秒、4 秒、8 秒...,累計 10 次失敗後硬鎖 15 分鐘
  • 密碼重置令牌:需為加密隨機生成、一次性使用,並在 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("帳戶暫時鎖定");
  }
}

避免

  • 將密碼以明文、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.

相關技能