implementing-api-key-security-controls

Featured

Implements secure API key generation, storage, rotation, and revocation controls to protect API authentication credentials from leakage, brute force, and abuse. The engineer designs API key formats with sufficient entropy, implements secure hashing for storage, enforces per-key scoping and rate limiting, monitors for leaked keys in public repositories, and builds key rotation workflows. Activates for requests involving API key management, API key security, key rotation policy, or API credential protection.

AI & Automation 36,355 stars 4443 forks Updated 2 months ago Apache-2.0

Install

View on GitHub

Quality Score: 94/100

Stars 20%
100
Recency 20%
75
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Implementing API Key Security Controls ## When to Use - Designing secure API key generation with sufficient entropy and identifiable prefixes for leak detection - Implementing server-side API key hashing (never storing keys in plaintext) with SHA-256 or bcrypt - Building key rotation workflows that allow zero-downtime key replacement for API consumers - Configuring per-key scoping to limit each API key to specific endpoints, IP ranges, and rate limits - Setting up automated monitoring for API key leakage in GitHub repos, logs, and client-side code **Do not use** API keys as the sole authentication mechanism for user-facing applications. API keys are best suited for server-to-server communication and developer access. ## Prerequisites - Secure random number generator (os.urandom, secrets module) for key generation - Database with proper encryption at rest for storing hashed API keys - Redis or similar store for key-to-metadata caching and rate limiting - Secret scanning tools (GitHub secret scanning, truffleHog, gitleaks) - Monitoring and alerting infrastructure for key usage anomalies ## Workflow ### Step 1: Secure API Key Generation ```python import secrets import hashlib import hmac import time import json from datetime import datetime, timedelta class APIKeyManager: """Manages secure API key lifecycle: generation, storage, validation, rotation.""" # Key format: prefix_base64random (e.g., sk_live_a1b2c3d4e5f6...) # Prefix identifies the key type and ...

Details

Author
mukul975
Repository
mukul975/Anthropic-Cybersecurity-Skills
Created
8 months ago
Last Updated
2 months ago
Language
Python
License
Apache-2.0

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category