Be Software Architecture Wise
Be Wise Apps

Leer en español · Lire en français · Auf Deutsch lesen

Chapter 8 of 12 · Intermediate to advanced

Security, Privacy and Compliance by Design

Security and privacy are qualities of a system's structure, decided by where trust boundaries lie, who may do what and where data travels. This chapter covers the principles of secure design, threat modelling with data-flow diagrams, STRIDE and attack trees, identity and access with OAuth 2.0 and OpenID Connect, encryption, key management and secrets, zero trust between services, software supply-chain security, privacy by design under the GDPR, and security in operation. It is for developers and architects who know the distributed and data architectures of Chapters 6 and 7 and must now make them safe.

Video introduction to Chapter 8

8 min · narrated, with captions
Listen only (audio)
Read the transcript

Welcome to Chapter 8, Security, Privacy and Compliance by Design. Most serious breaches are not caused by an exotic attack on cryptography. They come from structural decisions. An internal service that trusted every caller on the network. An administrator API that skipped an authorisation check. An access key committed to a repository. Each was an architectural choice about where trust lies, which component may do what, and where data travels.

This chapter is for developers and architects who know the distributed and data architectures of Chapters 6 and 7, and who must now make them safe. Every service boundary, queue, cache, replica and analytics copy adds to the attack surface. Distribution multiplies the trust boundaries, and data architecture decides how many copies of personal data exist and how long they live. The chapter treats security as a quality attribute designed into the structure, in the sense of Chapter 2's security scenarios, rather than a list of products bought at the end. It also assumes Chapter 0's section on networks, HTTPS and TLS. And it leads to Chapter 9, which keeps the secured system fast and running under stress.

The running example is the food delivery platform used throughout the course: customers, restaurants and couriers, an API gateway, ordering, payments, dispatch and notification services, an event stream and a data warehouse. Section eight point one sets out the vocabulary: confidentiality, integrity and availability, Saltzer and Schroeder's design principles from 1975, such as least privilege, then defence in depth, secure defaults and the OWASP Top 10. Section eight point two turns those principles into a repeatable design activity. You draw a data flow diagram with its trust boundaries, ask what can go wrong using STRIDE and attack trees, rate the risks, and decide on mitigations. Section eight point three covers who is calling: passwords, passkeys, sessions and tokens, OAuth with PKCE, OpenID Connect, and the main models for deciding what each caller may do. Section eight point four covers encryption in transit and at rest, password hashing, key management with envelope encryption, secrets, tokenisation, and the decision about what to encrypt where.

Here is one of the central ideas of Section eight point one, defence in depth, drawn along the path an order takes through the platform. At the top is the customer app, outside the trust boundary. It talks to the platform only over HTTPS, and nothing on the device is trusted by the platform. Inside the boundary, each layer adds its own controls. The edge absorbs floods of traffic, applies rate limits and blocks known attack patterns. The API gateway checks every token and rejects requests that do not match the API schema. The orders service checks that this customer may see this particular order. The database uses an account with least privilege, and it is encrypted at rest, with backups encrypted under separate keys. Security logging, detection and alerting run across every layer. Because each layer has its own controls, a single bypassed control does not expose the data.

The second four sections widen the view. Section eight point five replaces the idea of a trusted internal network with authentication and authorisation on every request between services, using mutual TLS, certificates, and separate points where policy is decided and enforced. Section eight point six treats dependencies, build systems and container images as part of the attack surface, with software bills of materials, signing, and the EU Cyber Resilience Act. Section eight point seven explains how the GDPR and the UK GDPR shape architecture: data minimisation, pseudonymisation, the rights of the people the data is about, retention, and erasure across backups and event logs. And Section eight point eight closes the loop with security logging, detection, vulnerability management, incident response and breach notification.

This diagram from Section eight point five shows what zero trust changes. Before, on a flat internal network, any host can reach any port, and every service shares one database. When the menu service is compromised, the attacker can go straight to payments. After, each service has its own database, and only named identities may make allowed calls. Orders calls payments over mutual TLS, with a policy. When the compromised menu service tries to call payments, it is denied. Notice what zero trust does not do. It does not stop a service being compromised. It limits what the compromised service can reach.

An architect does not need to be a penetration tester or a cryptographer, and should not invent cryptography. The architect makes the decisions that are expensive to change: where the trust boundaries lie, and which identity provider and token model the whole platform uses. Also which data is classified as restricted, and encrypted with which keys, and how services prove their identity to one another. These decisions belong in architecture decision records, like any other significant decision. Developers own an equally important set: validating input, encoding output, using the platform's security libraries correctly, handling errors without failing open, and keeping dependencies up to date. The two meet in threat modelling, in secure design reviews, and in automated checks in the delivery pipeline.

Security and privacy are full of numbered standards and legal provisions. The chapter names them precisely, gives the edition current at the time of writing, October 2026, and points to the authoritative source. The material on regulation explains how the law affects architecture. It is information, not legal advice. For a specific situation, an organisation's own lawyers and data protection officer remain the people to ask.

If you remember one thing from this chapter, make it this. Decide who and what your system trusts, for what, and why. Decide it deliberately, early and in writing, rather than leaving it implicit. And make every one of those trust decisions verifiable. Threat models, least privilege, OAuth scopes, envelope encryption, mutual TLS, signed builds and audit logs are all ways of replacing implicit trust with explicit, checkable trust. A system designed that way limits the damage of the breach that will eventually come, and can show its customers, auditors and regulators how it protects them.

Reading the sections in order works best. But each one also stands on its own, so you can go straight to the section you need. Allow about three and a half hours to read the whole chapter. At the end of each section there are self-check questions. Answer them in your head before you look at the answers. When you are ready, there is an optional chapter test, which takes about forty five minutes. It has twenty multiple choice questions and two written answers. The pass mark is eighty per cent.

That is the shape of the chapter. Start with Section eight point one, security principles for architects, where the vocabulary for everything that follows is set out. See you there.

Download chapter (PDF)Read in the app

At a glance

You will learn to

  • Apply the CIA triad, Saltzer and Schroeder's design principles, defence in depth and secure defaults to architectural decisions, and explain what architects own in a secure development lifecycle.
  • Threat-model a design using a data-flow diagram with trust boundaries, STRIDE and attack trees, and rate and record the resulting risks and mitigations.
  • Distinguish authentication from authorisation, choose between sessions and tokens, and explain OAuth 2.0 with PKCE, client credentials, OpenID Connect and RBAC, ABAC and relationship-based access control.
  • Decide what to encrypt, where and with which keys, using envelope encryption, a KMS, password hashing, secrets management and tokenisation.
  • Explain zero trust architecture and design service-to-service security with mutual TLS, workload identity and policy enforcement points.
  • Reduce software supply-chain risk with SBOMs, the SLSA framework, signing, pinning and isolated builds, and summarise the obligations of the EU Cyber Resilience Act.
  • Design for the GDPR's principles, data protection by design and by default, and data subjects' rights, including erasure across backups, caches and event logs.
  • Plan security logging, detection, vulnerability management and incident response, including the GDPR's 72-hour breach notification.

Before you start

Chapters 6 and 7, especially microservices, event-driven architecture and data ownership; Chapter 2's section on security as a quality attribute; Chapter 0's section on networks, HTTPS and TLS.

Time

About 3½ hours to read; 45 minutes for the test.

Key terms

trust boundary · least privilege · defence in depth · threat modelling · STRIDE · OAuth 2.0 · OpenID Connect · PKCE · envelope encryption · zero trust · mutual TLS · SBOM · pseudonymisation · crypto-shredding

Security is a property of the structure

Most serious breaches are not caused by an exotic cryptographic attack. They come from structural decisions: an internal service that trusted every caller on the network, an administrator API that skipped an authorisation check, a database backup copied to a storage bucket that anyone could read, an access key committed to a repository, a dependency nobody knew the system used. Each of these was an architectural choice, usually made implicitly, about where trust lies, which component may do what and where data travels. That is why this chapter treats security as a quality attribute designed into the structure, in the sense of Chapter 2's security scenarios, rather than as a list of products bought at the end.

It is also why security is inseparable from the styles of Chapters 6 and 7. Every service boundary, queue, cache, replica and analytics copy adds to the attack surface and creates another place where data must be protected. Distribution multiplies the number of trust boundaries; data architecture decides how many copies of personal data exist and how long they live. The running example is the food-delivery platform used throughout the course: customers, restaurants and couriers, an API gateway, ordering, payments, dispatch and notification services, an event stream and a data warehouse.

How the eight sections fit together

The first four sections build the core of secure design. Security principles sets out the vocabulary: the CIA triad, Saltzer and Schroeder's 1975 design principles such as least privilege and fail-safe defaults, defence in depth, secure defaults, the OWASP Top 10 and a secure development lifecycle based on NIST's SSDF. Threat modelling turns those principles into a repeatable design activity: draw a data-flow diagram with its trust boundaries, ask what can go wrong with STRIDE and attack trees, rate the risks and decide on mitigations. Identity and access covers who is calling: passwords as NIST now recommends, passkeys, sessions and tokens, OAuth 2.0 with PKCE, OpenID Connect, and the authorisation models RBAC, ABAC and relationship-based access control. Protecting data covers encryption in transit and at rest, password hashing, key management with envelope encryption, secrets, tokenisation and the decision about what to encrypt where.

The second four sections widen the view. Zero trust replaces the idea of a trusted internal network with per-request authentication and authorisation between services, using mutual TLS, certificates and policy decision and enforcement points. Supply-chain security treats dependencies, build systems and container images as part of the attack surface, with software bills of materials, the SLSA framework, signing and the EU Cyber Resilience Act. Privacy by design explains how the GDPR and the UK GDPR shape architecture: data minimisation, pseudonymisation, data subjects' rights, retention and erasure across backups and event logs. Security in operation closes the loop with security logging, detection, vulnerability management, incident response and breach notification.

What architects decide, and what they delegate

An architect does not need to be a penetration tester or a cryptographer, and should not invent cryptography. The architect's job is to make the decisions that are expensive to change and that no single team can make alone: where the trust boundaries lie, which identity provider and token model the whole platform uses, which component is the policy decision point for which resources, which data is classified as restricted and therefore encrypted with which keys, how services prove their identity to one another, and how the organisation will detect and respond to an attack. These decisions belong in architecture decision records and in the cross-cutting concepts of an arc42 description, like any other significant decision.

Developers own a different, equally important set of concerns: validating input, encoding output, using the platform's authentication and authorisation libraries correctly, handling errors without failing open, keeping dependencies up to date and writing tests for security behaviour. The two meet in threat modelling, in secure design reviews and in automated checks in the delivery pipeline. Where practitioners disagree, for example about how much security work to shift onto developers or how formal threat modelling should be, the chapter presents both positions.

Law, standards and accuracy

Security and privacy are full of numbered standards and legal provisions, and this chapter names them precisely: NIST special publications, IETF RFCs, OWASP projects, PCI DSS, the GDPR and the UK GDPR, and the EU Cyber Resilience Act. Standards change, so each mention gives the edition current at the time of writing (October 2026) and points to the authoritative source. The material on regulation explains how the law affects architecture; it is information, not legal advice, and an organisation's own lawyers and data protection officer remain the people to ask about a specific situation.

The one idea to take away

Decide deliberately, early and in writing who and what your system trusts, for what, and why, and make every one of those trust decisions verifiable. Most of the techniques in this chapter, from threat models and least privilege to OAuth scopes, envelope encryption, mutual TLS, signed builds and audit logs, are ways of replacing implicit trust with explicit, checkable trust. A system designed that way limits the damage of the breach that will eventually come, and can show its customers, auditors and regulators how it protects them.

The 8 sections

8.1 · Intermediate · 20 minSecurity principlesThe CIA triad, Saltzer and Schroeder's design principles, defence in depth, secure defaults, attack surface and trust boundaries, the OWASP Top 10 and a secure development lifecycle, with who owns what.Read →8.2 · Intermediate · 22 minThreat modellingShostack's four questions, data-flow diagrams with trust boundaries, STRIDE and attack trees, rating risk without false precision, and a worked threat model of a food-delivery checkout.Read →8.3 · Advanced · 26 minIdentity and accessAuthentication versus authorisation, NIST's current password rules, MFA and passkeys, sessions and JWTs, OAuth 2.0 with PKCE, OpenID Connect, RBAC, ABAC, relationship-based access and workload identity.Read →8.4 · Advanced · 26 minProtecting dataEncryption in transit and at rest and what each layer really protects, symmetric and asymmetric cryptography, password hashing, KMS and envelope encryption, secrets, tokenisation for PCI DSS and data classification.Read →8.5 · Advanced · 22 minZero trustWhy the trusted internal network failed, what NIST SP 800-207 and BeyondCorp mean by zero trust, and how mTLS, workload identity, service meshes, certificates and gateways put it into practice.Read →8.6 · Intermediate · 23 minSupply chainWhy dependencies and build pipelines are an attack surface, what event-stream, SolarWinds, Log4Shell and xz utils teach, and how SBOMs, SLSA, Sigstore, pinning and the EU Cyber Resilience Act respond.Read →8.7 · Intermediate · 24 minPrivacy by designHow the GDPR and UK GDPR shape architecture: Article 5 principles, data protection by design and by default, rights systems must support, DPIAs, transfers, pseudonymisation, retention and erasure across every copy.Read →8.8 · Intermediate · 24 minSecurity in operationRunning a system securely: what to log and never log, audit trails, SIEM detection, vulnerability management with CVSS, EPSS and KEV, NIST incident response, ransomware-proof backups and breach notification deadlines.Read →

Chapter test

Test your understanding of Chapter 8

Optional: 20 multiple-choice questions and 2 short written answers, drawn afresh from a bank of 72 questions. Pass mark 80%. Passing every chapter test, then the final assessment, earns the Be Wise Certificate of Completion.

Take the Chapter 8 test in the app

Further reading