brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
auth-system-setupWhen 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 ar…
Independent GitHub snapshot · Automated classification · Original documentation governs
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 boundaries