Implement comprehensive API security measures including authentication, authorization, rate limiting, input validation, and attack prevention to protect against common vulnerabilities.
Detailed implementations in the references/ directory:
Guide
Contents
Node.js/Express API Security
Node.js/Express API Security
Python FastAPI Security
Python FastAPI Security
API Gateway Security Configuration
API Gateway Security Configuration
Best Practices
✅ DO
Use HTTPS everywhere
Implement rate limiting
Validate all inputs
Use security headers
Log security events
Implement CORS properly
Use strong authentication
Version your APIs
❌ DON'T
Expose stack traces
Return detailed errors
Trust user input
Use HTTP for APIs
Skip input validation
Ignore rate limiting
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: aj-geddes-useful-ai-prompts-api-security-hardening3description: API Security Hardening4---56# API Security Hardening78## Table of Contents910- [Overview](#overview)11- [When to Use](#when-to-use)12- [Quick Start](#quick-start)13- [Reference Guides](#reference-guides)14- [Best Practices](#best-practices)1516## Overview1718Implement comprehensive API security measures including authentication, authorization, rate limiting, input validation, and attack prevention to protect against common vulnerabilities.1920## When to Use2122- New API development23- Security audit remediation24- Production API hardening25- Compliance requirements26- High-traffic API protection27- Public API exposure2829## Quick Start3031Minimal working example:3233```javascript34// secure-api.js - Comprehensive API security35const express = require("express");36const helmet = require("helmet");37const rateLimit = require("express-rate-limit");38const mongoSanitize = require("express-mongo-sanitize");39const xss = require("xss-clean");40const hpp = require("hpp");41const cors = require("cors");42const jwt = require("jsonwebtoken");43const validator = require("validator");4445class SecureAPIServer {46 constructor() {47 this.app = express();48 this.setupSecurityMiddleware();49 this.setupRoutes();50 }5152 setupSecurityMiddleware() {53 // 1. Helmet - Set security headers54 this.app.use(55 helmet({56 contentSecurityPolicy: {57 directives: {58 defaultSrc: ["'self'"],59// ... (see reference guides for full implementation)60```6162## Reference Guides6364Detailed implementations in the `references/` directory:6566| Guide | Contents |67|---|---|68| [Node.js/Express API Security](references/nodejsexpress-api-security.md) | Node.js/Express API Security |69| [Python FastAPI Security](references/python-fastapi-security.md) | Python FastAPI Security |70| [API Gateway Security Configuration](references/api-gateway-security-configuration.md) | API Gateway Security Configuration |7172## Best Practices7374### ✅ DO7576- Use HTTPS everywhere77- Implement rate limiting78- Validate all inputs79- Use security headers80- Log security events81- Implement CORS properly82- Use strong authentication83- Version your APIs8485### ❌ DON'T8687- Expose stack traces88- Return detailed errors89- Trust user input90- Use HTTP for APIs91- Skip input validation92- Ignore rate limiting9394---95> Converted and distributed by [TomeVault](https://tomevault.io/claim/aj-geddes) — claim your Tome and manage your conversions.96<!-- tomevault:4.0:skill_md:2026-04-11 -->
Run npx skillmds@latest add tomevault-io/aj-geddes-useful-ai-prompts-api-security-hardening in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
API Security Hardening It is listed under Security on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.