I have below code to bypass adding authentication during local development, I am using Azure AD & .NET Core.
#if !DEBUG
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(Configuration.GetSection("AzureAd"));
#endif
However since I have my controller protected by Authorize attribute, how do I bypass the Authorize attribute inside Controller during local development:
[Authorize(Roles = "Buyer")]
public class ProductController : ApiBaseController
{
}
In .NET Framework I have below code to override the Authorize attribute:
public class MyAuthorizeAttribute : AuthorizeAttribute
{
#if DEBUG
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
return true;
}
#endif
}
What is the equivalent code for .NET Core ? or is there any other way we can override Authorize attribute in Startup.cs class ?