Saltar al contenido
uencoder

API Seguridad Best Practices Referencia

Comprehensive referencia para API seguridad: authentication, authorization, entrada validation, y monitoring.

Authentication and Authorization

APIs should use strong authentication: OAuth 2.0 for delegated access, API keys for simple auth, mTLS for high security. JWTs must validate signature, expiry, issuer, and audience. Authorization checks must happen per-object (BOLA prevention) and per-property. Scope-based access control limits what actions a token allows. Least privilege: tokens should have minimal necessary scopes. Token rotation and revocation are essential for compromised credentials.

OAuth 2.0
Delegated access
authorization code
per-object
BOLA prevention
check every object
scopes
Minimal privileges
least privilege

Input and Output Security

Validate all input against strict schemas (JSON Schema, OpenAPI). Reject unknown fields to prevent mass assignment. Limit payload size and nesting depth to prevent DoS. Sanitize and encode output to prevent injection. Use parameterized queries for database access. Rate limit per-client to prevent abuse. Log all access for audit and anomaly detection. Version APIs to allow breaking changes safely. Deprecate insecure versions with clear timelines.

schema
Strict validation
reject unknown
size limit
Prevent DoS
payload + depth
logging
Audit trail
anomaly detection

Herramientas relacionadas

参考链接