【发布时间】:2017-08-25 05:08:44
【问题描述】:
在使用授权策略时,是否可以了解哪个策略没有成功?
理想情况下,我希望能够修改中间件管道中的数据,以更好地确定为什么将 403 返回给 API 使用者。
此时返回的只是 403;禁止。
[Authorize] // Azure auth
[Authorize(Policy="SessionIsValid")] // Ensure transaction sessions are valid
public class TaskController : Controller
{ /** code removed for brevity */ }
在 Statup.cs 的 configure 方法中是否可以理解策略失败的原因?
app.Use(async (context, next) =>
{
await next();
if (context.Response.StatusCode == 403 )
{
// which policy failed? need to inform consumer which requirement was not met
await next()
}
});
【问题讨论】:
标签: security .net-core authorize-attribute