We are currently in the process of moving from .Net MVC to a Vue.js front-end. In our MVC version, we have a custom Attribute that uses Azure AD to authenticate users at certain pages. The attribute would just check if they were already logged into Microsoft and if not, redirect them to our organization's login. Since making the move to Vue.js, we get a Cross-Origin Request Blocked error when attempting the redirect. Looking online, it seemed like we needed to move to the Non-API solution Microsoft offers with OpenId. We are still having the same Cross-Origin Request Blocked issue with that solution as well. I am not sure where to go from here. Below is how our Startup.cs is setup and the controller I am testing with.
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddCors();
services.AddHttpClient();
services.AddMemoryCache();
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(_configuration.GetSection("AzureAd"));
services.AddAuthorization(options =>
{
options.AddPolicy("AuthorizeAccess",
policy => policy.Requirements.Add(new Helpside.Domain.Attributes.AuthorizeAccessAttribute()));
});
}
Controller
[Authorize]
[HttpGet("Test")]
public JsonResult Test()
{
var response = "Test";
return Json(response);
}
