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.
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
