Highlights

Contents

Part I
01

Authentication vs authorization

We begin with a user opening a private score report. Knowing who sent a request does not decide whether the request is allowed. We will trace authentication, authorization, tenant boundaries, and denial before discussing credentials.

CHAPTER ATLAS / FOLLOW THE READING PATHCHAPTER ATLAS / FOLLOW THE READING PATH1Authentication vsauthorization2Sessions and cookies3JWT and API keys4OAuth 2.0 and PKCE5RBAC, ACLs, and resourcepolicy6Encryption and secrets7Password hashing andsigned URLs8CORS, CSRF and abuseprevention9Case study: securing oneoperation

#Section 1A known user can request someone else’s report

Heron receives a valid session for user Mira, who requests report 7 owned by another account. The login succeeded, but the read should fail unless the sharing rule permits it. Authentication establishes the request’s claimed identity under a credential protocol. Authorization decides whether that identity may perform a particular action on a particular resource.

The application first resolves the authenticated principal, then validates the requested action and resource, then evaluates policy using trusted ownership and tenant data. It does not treat a client-supplied owner_id as proof. A principal is the entity whose identity and permissions the system evaluates, such as a user or service.

A VALID LOGIN PROVES WHO YOU ARE, NOT THAT REPORT 41 IS YOURSA VALID LOGIN PROVES WHO YOU ARE, NOT THAT REPORT 41 IS YOURSverify credentialsignature, expiryresolve principaluser miraload resourcereport 41, owner?evaluate actionread: allow?check the requested resource, every time
Figure 18.1Illustrative private-report request. A valid credential does not grant ownership of every requested object.

Keep authentication middleware and object-level checks connected. A route-level rule saying logged-in users may read reports is insufficient for private reports. Every object lookup, export, thumbnail, search result, and download path must preserve the resource rule. Alternate routes are a common way a correct main page becomes an incorrect system.

#Section 2A tenant boundary is part of every lookup

A user in tenant 8 requests a document whose stored tenant is 7. The service must reject or omit that object under the cross-tenant policy. Tenant isolation prevents one customer or organization from accessing another’s data and operations except through explicitly permitted sharing.

Derive the request tenant from a trusted identity or validated membership context. Query resources within that tenant scope and verify their actual ownership. Include tenant in cache keys and analytical access rules. A globally unique document ID does not remove the need for authorization; uniqueness answers identity, not permission.

A REQUEST FROM TENANT 8 ASKING FOR AN OBJECT IN TENANT 7 IS DENIEDA REQUEST FROM TENANT 8 ASKING FOR AN OBJECT IN TENANT 7 IS DENIEDtenant 8request identitytenant 7stored object8 ≠ 7 and no sharing grant: deny. Cache keys carry the tenant too
Figure 18.2Illustrative tenant boundary using recorded identifiers. Numeric IDs have no implied privilege order.

A cache hit must satisfy the same scope as a database lookup. If the key contains only object ID and omits tenant or visibility context, a private result can cross the boundary without executing the correct database predicate. Cached search pages and object metadata need this check too. Speed cannot change which principal is permitted to receive the value.

An internal service call must preserve identity and scope or apply its own trusted service policy. Passing an unvalidated header like X-Tenant through several services can make the entire stack trust a client choice. Prefer a verified context with clearly defined issuers and recipients. The security boundary exists at each trust transition, not only at the internet edge.

#Section 3Deny rules need an explicit default

A new API endpoint ships without an ownership branch. If missing policy means allow, the endpoint becomes public accidentally. Default deny means an operation remains unauthorized unless a declared rule grants it. Policy errors and missing resource context must not silently become permission.

The service should evaluate the expected action against trusted attributes, return the chosen denial response, and record a bounded audit event where useful. Error wording can avoid exposing whether an inaccessible object exists, according to the product policy. The distinction between not-found and forbidden is a deliberate information boundary.

NO MATCHING GRANT MEANS DENY: THE DEFAULT IS WRITTEN INTO THE CODENO MATCHING GRANT MEANS DENY: THE DEFAULT IS WRITTEN INTO THE CODEaction + resourcetrusted contextgrant?allowyesdenyno / noneaudit the denial; word it so it does not reveal what exists
Figure 18.3Illustrative policy evaluation. The absence of a matching grant takes the denial branch.

Cache authorization decisions only with their scope, action, resource, principal, policy version, and expiry rules. A cached allow can outlive a permission removal. For sensitive operations, recheck at the effect boundary rather than rely on a long-lived UI result. A disabled button helps users but does not enforce the server’s policy.

#Section 4Put trust boundaries in the drawing

A diagram shows browser, edge, application, database, and object storage. Each receives data from another component with a different trust relationship. A trust boundary is a point where assumptions about input identity, authority, or integrity change. Marking it tells us where to validate and authenticate.

The browser can choose request fields but cannot choose its server-side identity. The edge may terminate TLS but must convey identity context through a protected validated path. The application can authorize a download but should not expose a storage account’s unrestricted credentials. The database should use a least-privilege service identity, not an administrator identity for ordinary requests.

FOUR HOPS, FOUR CONTRACTS: INTERNAL DOES NOT MEAN TRUSTEDFOUR HOPS, FOUR CONTRACTS: INTERNAL DOES NOT MEAN TRUSTEDbrowseruntrusted inputedgeauthenticatesapplicationauthorizesstoragescoped accessidentity travels on a protected, validated path between hops
Figure 18.4Illustrative trust boundaries. A network hop is protected according to its identity, integrity, and permission requirements.

Least privilege grants only the actions and scope needed for the job. It reduces the effect of a stolen credential or compromised component. It does not replace input validation or eliminate every attack. A service limited to one bucket prefix can still damage that permitted data, so protection and recovery remain necessary.