liveBook · Manning

Authorization decision

As explained in Grokking Web Application Security

An authorization decision is a determination of whether an authenticated principal may access a resource or perform an action.

An authorization decision answers a security-critical question: may this authenticated user perform this action on this resource? Authentication establishes who the user is; authorization enforces the permissions they should have. A wrong decision can expose another user’s data or let an attacker obtain greater privileges. section 10.0 section 10.20

Treat each decision as domain logic rather than generic plumbing. Define the categories of users, the resources they can reach, and the actions they may or may not take. Because these rules differ between applications and evolve with features, keep a shared design document that states the intended behavior. section 10.0 section 10.5

Make authorization decisions reliably by following a consistent process:

  • Identify the authenticated principal, requested action, and target resource before applying a rule. section 10.6
  • Use role-based access control (RBAC) for permissions associated with user categories, and attribute-based access control (ABAC) for rules involving particular users and resources. section 10.6
  • Base the decision only on validated, trusted data. Keep unvalidated HTTP claims separate from trusted session or database data. section 10.19 section 10.20
  • Enforce checks on the server. Client-side checks can improve usability but can be altered by an attacker. section 10.21
  • Choose and document the failure response for each route, such as a redirect, 403 Forbidden, or 404 Not Found. section 10.21

Messaging access decision

For a direct-message conversation, a user may read messages they sent or received, but not messages in conversations they do not participate in. A group-chat invitation can likewise determine whether a recipient may join. These are resource-specific decisions: the same user might be allowed to read one conversation and denied another. section 10.4 section 10.6

Test decisions against the documented rules, especially ambiguous and denied cases. Automated scanners cannot determine whether application-specific access rules are correct, so use critical review, QA where available, and automated unit tests to verify that actual behavior matches the design. section 10.13 section 10.14

public void testIllegalEdit() {
 User author    = new User(1, "theAuthor");
 Post post      = new Post(author, "Initial content");
 User otherUser = new User(2, "notTheAuthor");
 
 Assertions.assertThrows(IllegalEditException.class, () -> {
   post.edit(otherUser, "Updated content");
 });
}

This unit test verifies a denied decision: a user who did not author a post cannot edit it, and the model raises an exception. section 10.14

How Grokking Web Application Security covers it

How deep it goes
Explains design, RBAC and ABAC, trusted inputs, enforcement placement, failure responses, and testing rather than formal policy evaluation.
Examples
Uses messaging conversations, post editing, OAuth-granted contact access, and URL-level failure responses.
What it assumes
Assumes authenticated users, HTTP requests, and application resources while defining access control, RBAC, and ABAC.
What you can do after
Evaluate/understand whether access-control behavior matches documented rules and recognize unsafe decisions based on attacker-controlled input.
How it connects
Connects authentication, access control, RBAC, ABAC, trust boundaries, HTTP requests, MVC, and unit tests.

Also explained in

Compare how 7 books explain authorization decision →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Web Application Security. The section links point to the parts of the book it draws on.