I am using auth0 for user access with a react front end and .net server. I am trying to pass the jwt token to the backend for verification. However when I try to see if the user is authorized when debugging server the user is not authorized and they have 0 claims. Additionally if you look at the code below you can see the RoleClaimTyoe is pointed to a custom url retrieved from the Token. When debugging the access it seems to point towards the standard microsoft.identity path.
var domain = $"https://{builder.Configuration["Auth0:Domain"]}/";
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = domain;
options.Audience = builder.Configuration["Auth0:Audience"];
options.TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = ClaimTypes.NameIdentifier,
RoleClaimType = "https://xxxxxxx/roles"
};
});
builder.Services.AddAuthorization(options =>
{
options.AddPolicy("read:messages", policy => policy.Requirements.Add(new
HasScopeRequirement("read:messages", domain)));
options.AddPolicy("Admin", policy =>
policy.RequireRole("Administrator"));
});
I have tried many different ways to retrieve and validate the token but I am having 0 luck.