如果我的用户关联到我的 AspNetCore webapp 上所需的角色,为什么我会被禁止?

Why am I forbidden if my User is associated to the required Role on my AspNetCore webapp?

我正在尝试将角色添加到我的 AspNet Core WebApp,其中身份验证已经正常工作。

这是我在启动时所做的:

services
    .AddIdentity<User, Role>()
    .AddEntityFrameworkStores<IdentityContext>()
    .AddDefaultTokenProviders()
    .AddUserStore<UserStore<User, Role, IdentityContext, Guid>>()
    .AddRoleStore<RoleStore<Role, IdentityContext, Guid>>();

我为 User 提供了之前创建的角色 "Admin" 和 "SuperAdmin",并为给定的控制器操作添加了以下过滤器:

[Authorize(Roles = "Admin")] 

但是,当我尝试访问该端点时,我收到了 403 禁止。

我不明白我错过了什么。

我发现了一个与我类似的问题。 此人回答了他自己的问题,但没有将其标记为答案。

基本上,我似乎必须在生成的 JWT 中添加角色作为声明。