Complete Mediation
You'll learn why checking permissions once is never enough—and how to enforce authorization on every single access.
The Core Idea
Complete Mediation means never caching or skipping authorization checks. Every time a user or process attempts to access a resource—whether it's reading a file, calling an API endpoint, or querying a database record—you must verify their permissions from scratch. No shortcuts, no assumptions based on previous checks.
Think of it like airport security: even if you were cleared at Gate 1 an hour ago, you still get checked again at Gate 2. Your credentials don't grant you permanent, unquestioned access—they must be validated at each checkpoint.
Why This Matters
Imagine a web application that checks if a user can view a document when they first load the page, but then caches that decision in memory. If an administrator revokes that user's access while the page is still open, the cached authorization allows continued access to something they should no longer see. Complete Mediation prevents this by re-checking permissions on every subsequent request.
Common Pitfalls
- Caching authorization decisions in sessions or application memory
- Checking permissions once at the beginning of a long-running operation
- Assuming authorization state persists across multiple actions
- Front-end-only checks without server-side validation on each API call
The Pattern in Practice
Even if you checked permissions when the user navigated to /documents/123, you must check again when they click "Download," "Edit," or "Share." Each action is a separate access that requires independent authorization.
Key Takeaway: Treat every resource access as a new security decision—check permissions every time, never trust cached authorization state, and assume privileges can change at any moment.