mcpField
A
api-security-hardening

api-security-hardening

github.com/aj-geddesSecurity373864 installsUpdated 34w ago
Repository

About api-security-hardening

A skill for applying security controls to APIs, covering authentication, authorization, rate limits, input validation, and attack prevention. It includes implementation guides for Node.js/Express, Python FastAPI, and API gateways.

Key features

  1. 01Authentication and authorization
  2. 02Rate limiting
  3. 03Input validation
  4. 04Attack prevention
  5. 05Platform-specific implementation guides

Use cases

  1. 01Hardening a production API
  2. 02Remediating audit findings
  3. 03Securing a public API
  4. 04Preparing for compliance requirements

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill api-security-hardening

After installing, type/api-security-hardeningin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
api-gateway-security-configuration.md
nodejsexpress-api-security.md
python-fastapi-security.md
scripts/
security-checklist.sh

Details

From the project README

API Security Hardening

Table of Contents

Overview

Implement comprehensive API security measures including authentication, authorization, rate limiting, input validation, and attack prevention to protect against common vulnerabilities.

When to Use

  • New API development
  • Security audit remediation
  • Production API hardening
  • Compliance requirements
  • High-traffic API protection
  • Public API exposure

Quick Start

Minimal working example:

// secure-api.js - Comprehensive API security
const express = require("express");
const helmet = require("helmet");
const rateLimit = require("express-rate-limit");
const mongoSanitize = require("express-mongo-sanitize");
const xss = require("xss-clean");
const hpp = require("hpp");
const cors = require("cors");
const jwt = require("jsonwebtoken");
const validator = require("validator");

class SecureAPIServer {
  constructor() {
    this.app = express();
    this.setupSecurityMiddleware();
    this.setupRoutes();
  }

  setupSecurityMiddleware() {
    // 1. Helmet - Set security headers
    this.app.use(
      helmet({
        contentSecurityPolicy: {
          directives: {
            defaultSrc: ["'self'"],
// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
Node.js/Express API SecurityNode.js/Express API Security
Python FastAPI SecurityPython FastAPI Security
API Gateway Security ConfigurationAPI 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

Comments

Markdown supported