是否有可能为其添加默认控制策略不应使用的控制器动作例外?

问题描述 投票:0回答:1

如果我们希望我们的ASP.NET Core应用程序对除X动作之外的所有动作都使用默认的授权策略,除了定义单独的策略/使用将根据请求的URI对其进行过滤的授权过滤器之外,我们该如何做? ?

要向所有端点添加默认策略,我们可以在ConfigureServices方法中执行以下操作:

app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers()
                .RequireAuthorization();
            });
c# asp.net-mvc asp.net-core authorization policy-based-security
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.