Communitygithub.com

YepAPI/认证安全技能

会话认证、社交登录提供商、CSRF 保护以及安全 Cookie 模式的实现指南。

认证安全技能 是什么?

该技能提供了一整套构建安全 Web 应用程序认证体系的规则和最佳实践。它专注于会话管理,推荐对 API 间的通信使用 JWT,对面向用户的 Web 应用则采用基于会话的认证方式。技能涵盖了多种社交登录提供商(最低要求 Google 和 GitHub)、无密码魔法链接、基于角色的访问控制以及强大的 CSRF 防护。其核心在于通过使用 httpOnly 和安全 Cookie 来避免常见的前端存储漏洞,并强调使用 bcrypt 或 argon2 等经过验证的库进行密码哈希,而不是自行实现。该技能适用于任何需要健壮认证层的 Web 开发项目,尤其在 Next.js、Nuxt 或类似框架中,它提供了清晰的媒介件拦截、会话检查和 Cookie 配置模式,帮助开发者快速构建安全、可扩展的认证系统。

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

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

认证

规则

  • 基于会话的 Web 应用认证;仅 API 到 API 的通信使用 JWT
  • 路由保护中间件 —— 渲染前检查会话
  • 社交登录提供商:最低要求 Google + GitHub;根据受众添加更多
  • 魔法链接作为密码替代方案 —— 更简单,更安全
  • 基于角色的访问控制:使用 user.role 字段配合中间件检查
  • 所有变更端点必须启用 CSRF 保护
  • 安全 Cookie 设置:httpOnly、secure、sameSite: "lax"、合理的 maxAge
  • 刷新令牌轮换 —— 不要让令牌永久有效

避免

  • 将令牌存储在 localStorage 中 —— 应使用 httpOnly Cookie
  • 自行实现密码哈希 —— 应通过认证库使用 bcrypt/argon2
  • 仅依赖客户端角色检查而不进行服务器端验证
  • 表单提交缺少 CSRF 保护

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.

相关技能