Revert AllowAnonymous endpoint propagation
All checks were successful
Publish NuGets / build (release) Successful in 35s
All checks were successful
Publish NuGets / build (release) Successful in 35s
Remove the WithAllowAnonymousIfAttributePresent helper method. Authorization should be handled by IQueryAuthorizationService and ICommandAuthorizationService implementations, not by ASP.NET Core middleware. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
932ee6e632
commit
201768e716
@ -83,8 +83,7 @@ public static class EndpointRouteBuilderExtensions
|
||||
.Produces(200, queryMeta.QueryResultType)
|
||||
.Produces(400)
|
||||
.Produces(401)
|
||||
.Produces(403)
|
||||
.WithAllowAnonymousIfAttributePresent(queryMeta.QueryType);
|
||||
.Produces(403);
|
||||
}
|
||||
|
||||
private static void MapQueryGet(
|
||||
@ -147,8 +146,7 @@ public static class EndpointRouteBuilderExtensions
|
||||
.Produces(200, queryMeta.QueryResultType)
|
||||
.Produces(400)
|
||||
.Produces(401)
|
||||
.Produces(403)
|
||||
.WithAllowAnonymousIfAttributePresent(queryMeta.QueryType);
|
||||
.Produces(403);
|
||||
}
|
||||
|
||||
public static IEndpointRouteBuilder MapSvrntyCommands(this IEndpointRouteBuilder endpoints, string routePrefix = "api/command")
|
||||
@ -215,8 +213,7 @@ public static class EndpointRouteBuilderExtensions
|
||||
.Produces(200)
|
||||
.Produces(400)
|
||||
.Produces(401)
|
||||
.Produces(403)
|
||||
.WithAllowAnonymousIfAttributePresent(commandMeta.CommandType);
|
||||
.Produces(403);
|
||||
}
|
||||
|
||||
private static void MapCommandWithResult(
|
||||
@ -263,17 +260,6 @@ public static class EndpointRouteBuilderExtensions
|
||||
.Produces(200, commandMeta.CommandResultType)
|
||||
.Produces(400)
|
||||
.Produces(401)
|
||||
.Produces(403)
|
||||
.WithAllowAnonymousIfAttributePresent(commandMeta.CommandType);
|
||||
}
|
||||
|
||||
private static RouteHandlerBuilder WithAllowAnonymousIfAttributePresent(this RouteHandlerBuilder builder, Type type)
|
||||
{
|
||||
var allowAnonymousAttribute = type.GetCustomAttribute<Microsoft.AspNetCore.Authorization.AllowAnonymousAttribute>();
|
||||
if (allowAnonymousAttribute != null)
|
||||
{
|
||||
builder.AllowAnonymous();
|
||||
}
|
||||
return builder;
|
||||
.Produces(403);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user