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.
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.
Before generating any code, determine:
Create the auth flow diagram and data model:
For each OAuth provider:
Always use PKCE for public clients. Always validate the state parameter.
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
Create tests for:
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 testsPrompt: "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 boundariesnpx skills add TerminalSkills/auth-system-setup下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer