Managing secrets outside source code
Keeping passwords, API keys and tokens in a protected vault or environment variable, not in source code, and rotating keys and scanning commits for leaks.
Understanding Managing secrets outside source code in VCE Software Development U4O2
What it does: Listing .env in .gitignore stops Git from tracking the file that holds the secrets, so they are not committed. Rotating a key issues a new secret and retires the old one, which limits the damage if the old key has leaked. Secrets belong in protected configuration or a vault so they are not exposed to anyone who can read the code or repository. Version control keeps history, so a committed secret stays exposed even if it is deleted in a later commit. Rotation does not prevent theft, but it reduces the window of time in which a leaked key is useful to an attacker.
Common mistakes: The API key is hard-coded in the source, so anyone who can read the code or repository can steal it. It should be read from an environment variable: key = os.environ["API_KEY"]. Putting # in front turns the rule into a comment, so Git no longer ignores .env and the secrets in it can be committed. The line should be .env.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 49–72) and word search (Modules 49–130).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
secrets managementFill in the Blanks
Spot the Error
Student with a class code? Join your class →