auth-system-setup
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "auth-system-setup":https://skillpi.com/zh/skills/deepskill-f02befd970a6bf1f1a7b3eb2c737c658dc6abd2fb0e8b2df4be521fb2491a792。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
Auth-System-Setup:为 Web 应用设计和实现身份验证与授权。适用于涉及“auth、登录、OAuth、SSO、单点登录、基于角色的访问控制(RBAC)、权限、用户角色、访问控制、身份验证、授权”等场景,涵盖 OAuth 2.0 提供方集成、会话管理及角色/权限架构设计(JWT 相关任务请参考 jwt-handler;安全审查请参考 security-audit)。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 实测状态
- 未测试
文件浏览
Frontmatter
name: auth-system-setup
description: >-
When the user wants to set up authentication and authorization for a web application.
Use when the user mentions "auth," "login," "OAuth," "SSO," "single sign-on,"
"role-based access," "RBAC," "permissions," "user roles," "access control,"
"authentication," or "authorization." Covers OAuth 2.0 provider integration,
session management, and role/permission architecture. For JWT-specific tasks,
see jwt-handler. For security review, see security-audit.
license: Apache-2.0
compatibility: "Any backend framework (Node.js, Python, Go, etc.)"
metadata:
author: terminal-skills
version: "1.0.0"
category: development
tags: ["authentication", "authorization", "oauth", "rbac", "security"]Auth System Setup
Overview
Designs and implements complete authentication and authorization systems for web applications. Covers OAuth 2.0 provider integration (Google, GitHub, Microsoft), session and token management, role-based access control (RBAC), and permission architectures. Generates production-ready code, database migrations, and tests.
Instructions
1. Gather Requirements
Before generating any code, determine:
- Tech stack: Backend framework, database, frontend framework
- Auth method: OAuth providers, email/password, magic links, or combination
- Roles needed: What roles exist? What can each role do?
- Token strategy: Stateless JWT, server-side sessions, or hybrid
- Compliance: GDPR, SOC 2, HIPAA — affects data storage and logging
2. Design the Auth Architecture
Create the auth flow diagram and data model:
- User table: id, email, name, avatar, provider, provider_id, created_at
- Role table: id, name, description
- Permission table: id, resource, action (read/write/delete)
- Role-Permission mapping: role_id, permission_id
- User-Role mapping: user_id, role_id
- Refresh token table: id, user_id, token_hash, family_id, expires_at, revoked_at
3. Implement OAuth Flow
For each OAuth provider:
- Create provider configuration (client ID, secret, scopes, callback URL)
- Implement the authorization redirect with state parameter and PKCE
- Handle the callback: exchange code for tokens, extract user profile
- Provision or update the user record
- Issue application tokens (access + refresh)
Always use PKCE for public clients. Always validate the state parameter.
4. Implement RBAC
Generate the permission-checking middleware:
authorize(resource, action) → middleware function
1. Extract user from request (via JWT or session)
2. Load user roles and permissions (cache with TTL)
3. Check if any role grants the required permission
4. Return 403 with clear error if denied
For row-level security, add ownership filters:
filterByOwnership(resource) → middleware function
1. If user role has wildcard access, skip filter
2. Otherwise, add WHERE clause: resource.owner_id = user.id
3. Apply to SELECT, UPDATE, DELETE queries
5. Generate Tests
Create tests for:
- OAuth flow: successful login, invalid state, expired code
- Token lifecycle: issue, refresh, rotate, revoke
- RBAC: each role accessing allowed and denied resources
- Edge cases: expired tokens, revoked refresh tokens, role changes mid-session
Examples
Example 1: Express + PostgreSQL + Google OAuth
Prompt: "Set up Google OAuth with JWT tokens for my Express app. I need admin and user roles."
Output:
auth/providers/google.ts— OAuth 2.0 + PKCE flowauth/middleware/authenticate.ts— JWT verificationauth/middleware/authorize.ts— Role checkermigrations/001_auth_tables.sql— Users, roles, permissions, refresh_tokensauth/services/token.service.ts— JWT issuance with refresh rotationauth/routes.ts— /auth/google, /auth/callback, /auth/refresh, /auth/logouttests/auth.test.ts— 18 integration tests
Example 2: Django + GitHub OAuth + Multi-tenant RBAC
Prompt: "Add GitHub login to my Django app. Each organization has its own roles: owner, editor, viewer."
Output:
accounts/providers/github.py— OAuth integration via django-allauthaccounts/models.py— Organization, Membership, Role modelsaccounts/permissions.py— Per-organization permission backendaccounts/middleware.py— Org context middleware (from subdomain or header)accounts/decorators.py— @require_org_role('editor') decoratormigrations/0001_multi_tenant_auth.py— Schema migrationtests/test_permissions.py— 22 test cases across org boundaries
Guidelines
- Never store plain-text passwords — use bcrypt with cost factor 12+ or argon2id
- Always use PKCE for OAuth flows, even with confidential clients
- Rotate refresh tokens on every use — detect reuse to identify token theft
- Set short access token TTL — 15 minutes is the standard
- Cache permissions — reload on role change, not on every request
- Log auth events — login, logout, failed attempts, role changes (for audit trail)
- Rate limit auth endpoints — prevent brute force on login and token refresh
- Use httpOnly, Secure, SameSite=Strict cookies for refresh tokens in browsers
- Never put sensitive data in JWT payload — it's base64, not encrypted
当前收录版本
1.0.0
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供完整的身份验证和授权系统解决方案,涵盖OAuth 2.0、RBAC、会话管理等核心功能
- 适用于多种技术栈和框架,具有广泛的实用价值
- 包含生产就绪的代码生成、数据库迁移和测试用例
亮点
- 触发词覆盖全面,包括auth、login、OAuth、SSO、RBAC等关键术语
- 边界清晰,明确区分了与其他技能(jwt-handler、security-audit)的职责范围
亮点
- 结构清晰,包含Overview、Instructions、Examples、Guidelines等完整章节
- 提供了详细的步骤划分和端到端示例,便于理解和执行
- frontmatter完整,包含必要的元数据信息
亮点
- 提供了详细的安全最佳实践,如PKCE使用、令牌轮换、权限缓存等
- 覆盖了主要异常情况和边缘案例的测试建议
- 明确了不可逆操作的安全措施和审计日志要求
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
账号、密钥或授权
使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。
主文档提及 · 第 5, 7, 16, 23, 32 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。