I'm using an authentication middleware that is making API requests to a third party service. This middleware then sets up the claims that are later handled by an AuthorizationHandler in conjunction with a IAuthorizationRequirement and a custom policy.
The middleware piece works and I'm able to build the claims:
context.User.AddIdentity(identity); // contains claims
Where I'm stuck is redirecting to a specific URL (there are custom rules for where we need to redirect) from the handler or attribute. From the handler I tried:
var mvcContext = context.Resource as Microsoft.AspNetCore.Mvc.Filters.AuthorizationFilterContext;
mvcContext.Result = new RedirectToActionResult("login", "home", null);
but it's ignored; only a 401 is returned. AuthorizeAttribute
no longer has OnAuthorization so I can't use that either...
Thoughts? Thanks.