🗝️ Security · Security Fundamentals
Secrets Management
Keep passwords, keys, and tokens out of source code.
Secrets need controlled storage and rotation.
Store an API key in a secrets manager instead of Git.
💡 Don't tape the house key to the front door: keep it somewhere locked, and change the lock if it ever goes missing.
💡 Why it matters
A secret in source code spreads to every clone, branch, and backup, and once pushed it is hard to truly erase. Leaked keys are routinely scanned for and abused within minutes. Managing secrets properly keeps them out of code and lets you rotate them fast when needed.
🛠️ How to achieve it
⚠️ Signs of trouble
- •API keys or passwords appear directly in the code.
- •The same secret is reused across every environment.
- •Secrets are shared over chat or email.
- •No one knows how to rotate a key if it leaks.
🎯 Quick check
Score: 0/3Three questions to test the idea.
1. Where should an API key be stored?
Answer: In a secrets manager or secure config, not in the repo
Secrets belong in a dedicated store, kept out of source control where they would spread everywhere.
2. Why does rotation matter for secrets?
Answer: A leaked key can be replaced quickly to cut off access
Regular and on-demand rotation means a compromised secret can be revoked and swapped out fast.
3. A key was accidentally committed to Git. What is the right response?
Answer: Rotate the key and remove it from history
Once committed a secret may already be exposed, so you must rotate it and scrub it from history.
