1
當使用授權策略時,可以瞭解哪個策略不成功?ASPNET核心標識哪個需求策略失敗
理想情況下,我希望能夠修改中間件管道中的數據,以更好地確定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()
}
});