liveBook · Manning

Secret management

As explained in Grokking Software Architecture

Secrets management is the practice of securely storing, controlling access to, distributing, and rotating sensitive authentication data such as passwords and database credentials.

Secret management keeps database passwords and connection strings out of source code. Store them securely using a key vault or environment variables instead. section 8.7.3

Committing credentials in configuration files exposes them to anyone with repository access. It also makes rotation difficult: the unsafe setup may require a full code deployment to change credentials. section 11.5

Listing 11.1 The Hardcoded Disaster
import psycopg2
 
def get_db_connection():
    conn = psycopg2.connect( #A
        host="prod-db.internal.castle.com",
        database="orders_db",
        user="admin", #B
        password="Password123!" #C
    )
    return conn

This Python example hardcodes an admin username and password in a database connection—the kind of setup to avoid. section 11.5

How Grokking Software Architecture covers it

How deep it goes
Recommends key vaults or environment variables and shows the risks of hardcoding, without detailing setup.
Examples
Uses committed configuration and a Python database connection with hardcoded admin credentials as unsafe examples.
What you can do after
Configure database credentials outside source code using a key vault or environment variables.
How it connects
Connects credential handling to database security and least-privilege database accounts.

Also explained in

Compare how 8 books explain secret management →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.