liveBook · Manning

Credential

As explained in Grokking Software Architecture

A credential is information or an authorization artifact used to establish identity or obtain access to a protected resource.

Credentials are login details or secret values used to authenticate and access a protected service. They might let a vendor sign in to a portal or an application connect to a database. section 11.5.1 section 11.7

Hardcoding credentials creates avoidable risks:

  • Committing them to source control can expose them, even if they are later deleted. section 11.5.1
  • Using an administrator account gives a compromised service more access than it needs. section 11.5.1
  • Changing a hardcoded password requires rebuilding, retesting, and redeploying the application. section 11.5.1
Listing 11.2 Secure Runtime Retrieval Refactor
import boto3
import json
from botocore.exceptions import ClientError
 
def get_database_credentials():
    secret_name = "prod/BillingDatabase/Credentials"
    region_name = "us-east-1"
 
    # 1. Connect to the highly secure Secrets Manager
    session = boto3.session.Session()
    client = session.client(
        service_name='secretsmanager',
        region_name=region_name
    )
 
    try:
        # 2. Request the credentials at runtime
        get_secret_value_response = client.get_secret_value(
            SecretId=secret_name
        )
    except ClientError as e:
        raise e #A
 
    # 3. Parse the secure response
    secret_string = get_secret_value_response['SecretString']
    secret_dict = json.loads(secret_string)
    
    # 4. Return the credentials to be used by the ORM/Database connection
    return secret_dict['username'], secret_dict['password']
 
db_user, db_pass = get_database_credentials() #B
connect_to_database(db_user, db_pass)
 

The Python example keeps the secret itself out of application code: it requests credentials from AWS Secrets Manager at runtime using boto3. A short-lived, least-privilege IAM role lets the server make that request. section 11.5.1

A vendor login becomes a path inward

In the Target HVAC breach, attackers stole a vendor’s portal login credentials through phishing. They then moved from the billing network into the retail network, where they reached point-of-sale systems. section 11.7

How Grokking Software Architecture covers it

How deep it goes
Contrasts hardcoded database secrets with runtime retrieval and traces stolen vendor logins into a larger breach.
Examples
Uses a Python AWS Secrets Manager retrieval pattern and stolen HVAC-vendor credentials in Target’s 2013 breach.
What you can do after
Configure applications to fetch secrets at runtime through a short-lived, least-privilege server IAM role.
How it connects
Connects credentials to secrets management, IAM roles, least privilege, phishing, and network segmentation.

Also explained in

Compare how 10 books explain credential →

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.