AdvancedBackendFree prompt

Complete Authentication System with JWT, Refresh Tokens, and RBAC

Secure authentication and authorization implementation with rotating tokens and role-based access control.

Build a robust authentication and authorization system that protects the API against common attacks and implements granular permission control.

At a glance

Access

Free prompt

Open to copy without upgrading.

Prompt objective

Build a robust authentication and authorization system that protects the API against common attacks and implements granular permission control.

Real use case

A B2B SaaS platform needs an auth system supporting: email/password login, Google OAuth, member invitations to workspaces, 4 different roles (owner, admin, editor, viewer), and sessions on multiple devices with individual revocation.

Customize these fields first

PROJECT NAMENODE.JS/PYTHONFRAMEWORK: NestJS/Fastify/FastAPI/DjangoEMAIL+PASSWORD, GOOGLE OAUTH, MAGIC LINKLIST ROLES WITH PERMISSIONSYES/NO15 MINUTES7 DAYS

Replace the placeholders with your own context before you run the prompt. That usually improves the first output more than adding more instructions later.

Prompt

Implement a complete authentication and authorization system for [PROJECT NAME], built with [NODE.JS/PYTHON] and [FRAMEWORK: NestJS/Fastify/FastAPI/Django].\\\\\\\\n\\\\\\\\n**Requirements:**\\\\\\\\n- Login methods: [EMAIL+PASSWORD, GOOGLE OAUTH, MAGIC LINK]\\\\\\\\n- Roles: [LIST ROLES WITH PERMISSIONS]\\\\\\\\n- Multi-tenant: [YES/NO] — each workspace has its own members\\\\\\\\n- Simultaneous sessions: [YES/NO] — multiple devices\\\\\\\\n\\\\\\\\n**1) JWT Authentication Flow:**\\\\\\\\n- Access token: [15 MINUTES] duration, minimal payload (userId, role, tenantId)\\\\\\\\n- Refresh token: [7 DAYS] duration, rotation on each use (RTR)\\\\\\\\n- Token storage: httpOnly cookies (not localStorage)\\\\\\\\n- Silent renewal flow (frontend interceptor)\\\\\\\\n- Revoked refresh token blacklist (Redis)\\\\\\\\n\\\\\\\\n**2) Registration and Onboarding:**\\\\\\\\n- Signup with email validation (confirmation token)\\\\\\\\n- Password strength verification (zxcvbn)\\\\\\\\n- Rate limiting on auth endpoints (5 attempts/15min)\\\\\\\\n- Email member invitations with temporary token\\\\\\\\n\\\\\\\\n**3) OAuth 2.0 (Google):**\\\\\\\\n- Authorization Code flow with PKCE\\\\\\\\n- Linking OAuth account with existing account\\\\\\\\n- First login: auto-create account\\\\\\\\n- Minimum required scopes\\\\\\\\n\\\\\\\\n**4) RBAC (Role-Based Access Control):**\\\\\\\\n- Permission table: \\\\\\\\\\\\\\\\\\\\\\\`role → resource → action (create/read/update/delete)\\\\\\\\\\\\\\\\\\\\\\\`\\\\\\\\n- Reusable authorization middleware\\\\\\\\n- Per-endpoint guard/decorator: \\\\\\\\\\\\\\\\\\\\\\\`@Roles('admin', 'editor')\\\\\\\\\\\\\\\\\\\\\\\`\\\\\\\\n- Resource-level permissions (e.g., can only edit own posts)\\\\\\\\n- 403 response with actionable message\\\\\\\\n\\\\\\\\n**5) Security:**\\\\\\\\n- CSRF protection (SameSite cookies + token)\\\\\\\\n- Brute force protection (progressive delays)\\\\\\\\n- Account lockout after [NUMBER] attempts\\\\\\\\n- Login audit (IP, device, geolocation)\\\\\\\\n- Logout from all devices\\\\\\\\n- Secure password reset (single-use token, expires in 1h)\\\\\\\\n\\\\\\\\n**6) Complete Code:**\\\\\\\\n- Database models/schemas\\\\\\\\n- Authentication and authorization middleware\\\\\\\\n- Auth controllers/routes (register, login, refresh, logout, reset-password)\\\\\\\\n- Unit and integration tests for each flow\\\\\\\\n\\\\\\\\nUse [BCRYPT/ARGON2] for password hashing. Consider LGPD compliance.

Open directly in an AI — the text is pre-filled:

How to use this prompt

  1. 1Replace the key placeholders first: PROJECT NAME, NODE.JS/PYTHON, FRAMEWORK: NestJS/Fastify/FastAPI/Django, EMAIL+PASSWORD, GOOGLE OAUTH, MAGIC LINK.
  2. 2Replace any bracketed placeholders like [this] with your own context.
  3. 3Add extra background information when you want more tailored results.
  4. 4Combine multiple prompts in one conversation when you need a richer output.
  5. 5Save your best-performing prompts so they are easy to reuse later.

Next best step

Open the guide first, then branch only if you still need more.

A guide for technical builders choosing between prompts, coding workflows, and agent-based implementation.

If this prompt is close but not quite right, generate variants next. If the job is recurring, move into the course library after the guide.

Related prompts

View all

Explore other prompt categories

Move sideways into adjacent libraries when the current category is not the full answer.

Free browsing stays open. Premium prompts unlock the reusable workflow layer.

Use the guides and role paths to validate the job first. Upgrade when you want the full prompt text, editable premium prompts, and the surrounding course paths in one place.

Free access

  • Browse guides, role paths, and category pages.
  • Preview prompts before you decide to upgrade.
  • Find the right starting point without friction.

Membership access

  • Unlock premium prompts and the full copy text.
  • See more workflow paths and course connections.
  • Keep the reusable templates in one place.
Chat on WhatsApp