I have an ASP.NET Core 2.0 Razor Pages application that is hooked up to AAD v2.0 auth.
I'm adding the following policy:
options.AddPolicy("DelegatedAdmin", policy => policy.RequireClaim("DelegatedAdmin"));
I am using the following Attribute on pages .cs
[Authorize(Policy = "DelegatedAdmin")]
Functionally, this works. However, the error that is thrown when the user does not have that claim, the application throws a 502 Bad Gateway error. I'm thinking the failure of the policy is causing a loop to have the user log in which gets killed and this error bubbles up. Is there graceful way to handle this error? I've tried using app.UseStatusCodePages() but it doesn't seem to do anything.
TIA for any suggestions, -joe