I use middleware for authentication that handles API requests for a third-party service. This middleware then establishes the claims that are later processed by the AuthorizationHandler in conjunction with the IAuthorizationRequirement and user policy.
The intermediate link works, and I can build the formulas:
context.User.AddIdentity(identity);
Where I am stuck is redirected to a specific URL (there are special rules for where we need to redirect) from a 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 he is ignored; only 401 is returned. AuthorizeAttribute no longer has OnAuthorization, so I cannot use this ...
Thoughts? Thanks.
source share