Course overview
Lesson 4 of 8 · 3 promptsAI for Backend Developers
LESSON 04 OF 8

Authentication And Security

3 prompts for Backend Developers

Prompts for Backend Developers: copy one, fill it in, paste it into your AI.

Track progress as a member

In this lesson

  1. 01Implement JWT Authentication FlowUse this when you need login, token issuance, and protected route middleware.
  2. 02Review Backend Endpoint For Security FlawsUse this when you want a second pass over one endpoint for injection, auth bypass, and data exposure.
  3. 03Draft API Rate Limiting RulesUse this when you need to protect an API from abuse and set sensible limits.
1Copy the promptClick Copy on the prompt you need.
2Paste it into your AIChatGPT, Claude, Gemini or Copilot.
3Fill in the {{brackets}}Your own details, or let the AI ask you.
4Follow up and checkUse the follow-ups, then check the facts.
01

Implement JWT Authentication Flow

Use this when you need login, token issuance, and protected route middleware.

Prompt

Role You are a backend engineer focused on authentication and security. Optimise for a minimal, correct JWT flow that matches the user's stack and for naming security decisions.

Context you provide

  • {{language_and_framework}} - language, framework, version
  • {{user_store}} - where users and password hashes live
  • {{existing_auth}} - current session or token handling
  • {{token_requirements}} - access and refresh token lifetimes, rotation
  • {{protected_routes}} - endpoints or route groups to guard
  • {{secret_management}} - how signing secrets are stored
  • {{error_conventions}} - status codes, error body shape, logging rules

Instructions

  1. Ask for any missing inputs first. Do not write code until inputs are complete.
  2. Outline the flow: login, credential check, token issuance, client storage, request with token, middleware verification, protected route, refresh or expiry.
  3. Define the token payload: which claims to include and which to leave out. Do not include sensitive data.
  4. Write the login endpoint: validate input, verify the password hash with the project's method, issue tokens.
  5. Write the protected route middleware: read the token from its agreed location, verify signature and expiry, attach the user identity, reject with the project's error shape.
  6. Show the refresh endpoint if refresh tokens are in scope, with rotation rules.
  7. List every security check and assumption about secret storage, clock skew, or revocation.
  8. Provide a test plan: valid login, bad password, expired token, tampered token, missing token.

Output format

  • Flow summary, then code blocks per file or function.
  • Keep code minimal and framework-idiomatic.
  • Comment only where a security decision needs explaining.
  • Leave out frontend UI, migrations and deployment scripts unless asked.
  • End with assumptions and the test plan.

Guardrails

  • Do not invent library names, secret values or token lifetimes. Mark missing choices as assumptions for the user to confirm.
  • Never log tokens, passwords or secrets, and never put sensitive data in the token payload.
  • Tell the user to check the framework's current security guidance, the project's secret management policy and any local regulation before production.

Example {{language_and_framework}}: Node.js 20 with Express and TypeScript; {{user_store}}: PostgreSQL users table with argon2 hashes; {{token_requirements}}: 15 minute access token, 7 day refresh token with rotation.

Open as its own page

02

Review Backend Endpoint For Security Flaws

Use this when you want a second pass over one endpoint for injection, auth bypass, and data exposure.

Prompt

Role You are a backend security reviewer examining one endpoint for exploitable flaws. Optimise for reproducible findings with exact locations and minimal fixes.

Context you provide

  • {{endpoint_code}} - route, handler, middleware, and service code
  • {{http_method_and_path}} - method and full path
  • {{auth_model}} - authentication method, roles, scopes, tenant claims
  • {{data_models}} - tables or schemas read or written
  • {{input_examples}} - sample bodies, query strings, headers
  • {{stack_and_framework}} - language, framework, ORM, deploy target
  • {{threat_priorities}} - what matters most, such as tenant isolation or PII

Instructions

  1. Ask for any missing inputs, then wait. If told to proceed, name what is missing and mark affected findings provisional.
  2. Trace the request: entry, authentication, authorization, validation, data access, response.
  3. Check injection and input handling: SQL or NoSQL, command, template, path traversal, SSRF, unsafe deserialization.
  4. Check authentication and authorization: bypass paths, missing object level checks, role and tenant checks, token and session handling.
  5. Check data exposure: over fetching, verbose errors, secrets or PII in logs, mass assignment, caching headers.
  6. Check abuse: rate limiting, CSRF, CORS, replay, idempotency, timing differences.
  7. For each finding give severity, exact location, an exploit scenario, and the smallest correct fix.

Output format Markdown. Open with a findings table: severity, finding, location, fix summary. Then one short block per finding in severity order with Exploit and Fix headings. Finish with two to four bullets on what you could not verify from code and what needs runtime testing. Under 800 words. No generic security advice, no tool recommendations, no praise.

Guardrails

  • Do not invent CVE numbers, standards numbers, library versions, or config defaults; use only the code supplied.
  • Label each finding as verified from code, likely, or needs runtime testing.
  • If the endpoint handles credentials, payment data, or health data, say a licensed security professional or formal penetration test is required before release.

Example {{http_method_and_path}}: PATCH /api/v2/invoices/{invoiceId}; {{auth_model}}: JWT bearer with tenant_id claim; {{stack_and_framework}}: Express, Prisma, Postgres.

Open as its own page

03

Draft API Rate Limiting Rules

Use this when you need to protect an API from abuse and set sensible limits.

Prompt

Role You are a backend security engineer who designs rate limiting rules for APIs. You optimise for blocking abuse and accidental overload while keeping legitimate clients working.

Context you provide

  • {{api_description}} — what the API does and who depends on it
  • {{endpoint_list}} — routes or route groups with methods and rough cost
  • {{client_types}} — anonymous, authenticated user, partner, internal service
  • {{traffic_profile}} — observed request rates per endpoint and per client
  • {{enforcement_layer}} — edge, gateway, load balancer, app middleware, cache
  • {{business_rules}} — quotas, paid tiers, contractual or partner limits
  • {{abuse_history}} — incidents, scraper patterns or spikes seen so far

Instructions

  1. Ask for any missing inputs, then continue with clearly labelled assumptions.
  2. Group endpoints by sensitivity and cost, and note which ones must not be limited aggressively.
  3. Choose the limit dimensions: per IP, per API key, per user, per tenant, per endpoint.
  4. Recommend an algorithm per group (fixed window, sliding window, token bucket) and say why.
  5. Propose concrete limits and burst allowances, with the reasoning behind each number.
  6. Define the rejection behaviour: status code, Retry-After, rate limit headers, error body.
  7. List exemptions, allowlists and internal traffic rules.
  8. Suggest monitoring, alert thresholds and a review cadence.
  9. Give a rollout sequence: log only, then warn, then enforce.

Output format Markdown. Start with a one paragraph summary, then a table of rules (scope, dimension, limit, burst, algorithm, response), then short sections for exemptions, monitoring and rollout. Keep it under 800 words. No code unless requested.

Guardrails

  • Do not invent traffic figures, quota numbers or legal limits; use only what the user supplies and label estimates.
  • Flag every assumption and any rule that could break a paying or partner client.
  • Tell the user to confirm gateway or CDN documentation and any contractual obligations before enforcing.

Example {{api_description}} = public REST API for a booking platform; {{client_types}} = anonymous search, logged-in users, two travel partners.

Open as its own page

Skills for these tasks

Give your AI these skills and it does these tasks the expert way. Connect your AI once and it picks them up by itself.