[Blazor] Better way to configure some of the "internal" blazor endpoints
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
When you do things like call `RequireAuthorization` on the Blazor builder, all the endpoints start requiring auth, including endpoints like `_framework/opaque-redirect` or `_blazor/initializers`.
Reconfiguring these endpoints is "kind of painful" (see code below) because you need to "find the endpoint" and then apply the attribute.
```csharp
var components = app.MapRazorComponents()
.AddInteractiveServerRenderMode()
.RequireAuthorization();
components.Add(e => {
if(e is RouteEndpointBuilder rb)
{
if(rb.RoutePattern!.RawText!.Contains("_blazor")){
rb.Metadata.Add(new AllowAnonymousAttribute());
}
}
});
```
Ideally, we want to have some level of "first class support" for targeting these endpoints to add conventions to them without the user having to dig the details. Something like `ConfigureFrameworkEndpointsMetadata` that receives a callback to add metadata to those endpoints (we wouldn't expose stuff that allowed changing routes, etc. Since that's hardcoded in a bunch of places.
Contributor guide
Assessment
This issue has not been assessed yet.