После перемещения проекта в . net8 (обновление платформы Microsoft.AspNetCore.App до версии 8.0.7). Я начал получать ошибки 403.
Вот мое удостоверение, настроенное в builder.ConfigureServices():
Код: Выделить всё
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer("Bearer", options =>
{
options.Authority = "id.YouDontNeedToKnow.example.com";
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateAudience = false,
NameClaimType = "sub",
RoleClaimType = "role",
ValidTypes = [ "at+jwt" ]
};
});
builder.Services.AddAuthorization(options =>
{
options.AddPolicy(
"Admin",
AuthorisationPolicies.Admin());
});
Код: Выделить всё
RolesAuthorizationRequirement:User.IsInRole must be true for one of the following roles: (Admin)Подробнее здесь: https://stackoverflow.com/questions/790 ... te-to-net8
Мобильная версия