如果我们希望我们的ASP.NET Core应用程序对除X动作之外的所有动作都使用默认的授权策略,除了定义单独的策略/使用将根据请求的URI对其进行过滤的授权过滤器之外,我们该如何做? ?
要向所有端点添加默认策略,我们可以在ConfigureServices
方法中执行以下操作:
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers()
.RequireAuthorization();
});