liveBook · Manning

Identity and access management

As explained in Grokking Software Architecture

Identity and access management comprises policies and controls for verifying identities and authorizing their access to resources.

Identity and access management (IAM) is the portcullis of a layered security system: it checks who is making a request and whether they are allowed to make it. These checks apply to users and internal services, not just traffic at the network boundary. section 11.2.2

A server that needs a database password should not carry a permanent, hardcoded credential. Instead, it can use a short-lived IAM role to request that secret at runtime. Grant only the permission it needs—such as reading one specific secret—and let the cloud provider rotate the temporary role credentials. section 11.5.1

This approach avoids several avoidable headaches:

  • Credentials do not end up in source-control history. section 11.5.1
  • A breached service has less authority than an all-powerful database account. section 11.5.1
  • Changing a secret does not require rebuilding 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 requests a named secret from AWS Secrets Manager at runtime rather than embedding its value in the application. section 11.5.1

How Grokking Software Architecture covers it

How deep it goes
Explains authentication, authorization, and runtime secret retrieval, but stops short of detailing IAM role configuration.
Examples
Uses a server role to retrieve a database secret from AWS Secrets Manager in Python.
What you can do after
Operate a server with a short-lived, least-privilege role to retrieve a specific secret at runtime.
How it connects
Connects IAM with authentication, authorization, least privilege, defense in depth, and secrets management.

Also explained in

Compare how 6 books explain identity and access 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.