← API Security learning pathAPI Security · Module 6 of 8
Transport security and secrets
Encrypt traffic and keep keys out of reach.
📖 Key ideas
- Use HTTPS (TLS) for every request; redirect or refuse plain HTTP.
- Never put secrets such as API keys in mobile apps, frontend code or Git; anything shipped to users can be read.
- Keep secrets in a secret manager or environment configuration with limited access.
- Rotate keys regularly and immediately when they may have leaked.
- Give each key the least permission it needs and set CORS to only the origins that should call your API from browsers.
💡 Real-life example: Putting an API secret inside a mobile app is like hiding a house key under the doormat: anyone who looks for it will find it.
TLSEncryption protecting data in transit (HTTPS)
Secret managerService that stores and controls access to secrets
Key rotationReplacing keys with new ones
CORSBrowser rule for which websites may call an API