liveBook · Manning

Forbid response

As explained in ASP.NET Core in Action, 3e

A forbid response indicates that an authenticated user lacks the authorization requirements needed to access an endpoint or execute an operation.

A forbid response means the request came from an authenticated user who lacks an authorization requirement, such as a required claim. AuthorizationMiddleware stops the request before the endpoint runs. section 24.2.2

Distinguish a forbid response from the other authorization outcomes:

  • Allow the request when the authenticated user meets the endpoint’s requirements. section 24.2.2
  • Return a challenge response when the user is not authenticated. section 24.2.2
  • Return a forbid response when the user is authenticated but lacks permission. section 24.2.2
Figure 24.3 The three types of response to an authorization attempt. In the left example, the request contains an authentication cookie, so the user is authenticated in the AuthenticationMiddleware. The AuthorizationMiddleware confirms that the authenticated user can access the selected endpoint, so the endpoint is executed. In the center example, the request is not authenticated, so the Authorization-Middleware generates a challenge response. In the right example, the request is authenticated, but the user does not have permission to execute the endpoint, so a forbid response is generated.
CH24_F03_Lock3

Compare an allowed request, a challenge response, and a forbid response as authentication and authorization middleware process an endpoint request. section 24.2.2

With cookie authentication in a traditional web application, a forbid response redirects an already logged-in user to a forbidden or access-denied page rather than the login page. section 24.2.2

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains middleware flow and contrasts forbid with challenge responses, but does not detail API-specific response formats.
Examples
Uses missing claims, protected endpoints, authentication cookies, and access-denied pages as concrete examples.
What it assumes
Assumes authentication and authorization middleware concepts while distinguishing their roles in processing protected endpoints.
What you can do after
Evaluate authorization outcomes by distinguishing denied authenticated requests from unauthenticated challenge requests.
How it connects
Connects authorization middleware with authentication middleware, endpoint middleware, claims, challenge responses, and cookie authentication.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.