I am using both Auth0 forlogin and Asp.net core webapi identity (Front end-Reactjs and backend=Asp.net core webapi) and using an [Authorize] attribute, By default, it is taking identity authentication and it's redirecting to the Account/Login page Even though I add the default authentication as JwtBearerDefaults in the configuration services
Note: Auth0 authentication is working when I use the [Authorize] attribute in a different solution without identity but when I implement identity as well then [Authorize] working for identity only not for Auth0
Should restrict URL going to Account/Login by default in Asp.net core web API when using identity and accept Auth0 authentication by default
The below code is working for me without using asp.net core identity
Configureservices
services.AddAuthentication(options =>
{
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer(options =>
{
options.Authority = "https://xxxxxx.uk.auth0.com";
options.Audience = "xxxxx";
};
Controller
[HttpGet]
[Authorize]
public IList<UserDto> Get()
{
return _userService.GetUsers();
}
Expecting: By default Auth0 authentication should happen even though if I use Asp.net core web API Identity