-
Notifications
You must be signed in to change notification settings - Fork 10.7k
SkipStatusCodePagesAttribute should run before AuthorizeAttribute #10317
Copy link
Copy link
Closed
Labels
affected-mediumThis issue impacts approximately half of our customersThis issue impacts approximately half of our customersbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-mvc-execution-pipelineFeatures related to how MVC executes a controller or razor pageFeatures related to how MVC executes a controller or razor pageold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labelsseverity-minorThis label is used by an internal toolThis label is used by an internal tool
Milestone
Metadata
Metadata
Assignees
Labels
affected-mediumThis issue impacts approximately half of our customersThis issue impacts approximately half of our customersbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-mvc-execution-pipelineFeatures related to how MVC executes a controller or razor pageFeatures related to how MVC executes a controller or razor pageold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labelsseverity-minorThis label is used by an internal toolThis label is used by an internal tool
Type
Fields
Give feedbackNo fields configured for issues without a type.
Is your feature request related to a problem? Please describe.
[SkipStatusCodePages]is meant to be used in actions that are API calls, so that the StatusCodePagesMiddleware does not interfere with the response status code and body.API actions are almost always decorated with
[Authorize]. When user is not authorized, AuthorizeFilter short circuits and returns 401. Due to the short circuit, IResourceFilter, which SkipStatusCodePagesAttribute inherits, does not run, thus StatusCodePagesMiddleware runs and modifies the status code and body. The API caller does not receive 401 with empty body.Describe the solution you'd like
Ideally, the StatusCodePagesMiddleware does not run when
[SkipStatusCodePages], thus the API caller receives 401 with empty body.This can be achieved by having SkipStatusCodePagesAttribute inherit from IAlwaysRunResultFilter instead.
Describe alternatives you've considered
Modifying the middleware pipeline with custom middleware. But this dissociates the action that needs SkipStatusCodePages from the code that does the work
Additional context