Skip to content

[AspNetCore] Authorization resource in endpoint routing will now be HttpContext #19034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
HaoK opened this issue Jun 20, 2020 · 3 comments
Closed
Assignees
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 5 Work items for the .NET 5 release

Comments

@HaoK
Copy link
Member

HaoK commented Jun 20, 2020

[AspNetCore] Authorization resource in endpoint routing will now be HttpContext

Prior to this change, when using endpoint routing, the resource used for authorization would be the endpoint. This was insufficient to get access to the route data. Previously in MVC, the resource that was passed in was HttpContext which allows access to both the Endpoint and RouteData. This change just makes it so the resource passed into Authorization is always the HttpContext.

Version introduced

5.0-preview7

Old behavior

When using Endpoint routing and the AuthorizationMiddleware/AuthorizeAttributes, the resource passed into Authorization would be the matching Endpoint.

New behavior

Endpoint routing will now pass in the HttpContext into Authorization.

Reason for change

You can get to the Endpoint from the HttpContext, but there was no way to get from the Endpoint to things like the RouteData, so this was a loss in functionality from non endpoint routing.

Recommended action

If your app was using the Endpoint resource before, you will simply need to call GetEndpoint() on the HttpContext to continue to access the endpoint.

Category

  • ASP.NET Core

Affected APIs

 "Not detectable via API analysis"

Issue metadata

  • Issue type: breaking-change
@dotnet-bot dotnet-bot added ⌚ Not Triaged Not triaged breaking-change Indicates a .NET Core breaking change labels Jun 20, 2020
@gewarren gewarren self-assigned this Jun 22, 2020
@gewarren gewarren added doc-idea 🏁 Release: .NET 5 Work items for the .NET 5 release and removed ⌚ Not Triaged Not triaged labels Jun 22, 2020
@gewarren
Copy link
Contributor

@scottaddie Maybe this falls under your area? What do you think?

@scottaddie
Copy link
Member

@HaoK Can you please move this issue to the aspnet/Announcements repo?
@gewarren I'll take care of documenting this breaking change.

@HaoK
Copy link
Member Author

HaoK commented Jun 24, 2020

moved to aspnet/Announcements#423

@HaoK HaoK closed this as completed Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 5 Work items for the .NET 5 release
Projects
None yet
Development

No branches or pull requests

4 participants