我将在Asp.Net Core 2.1中使用IdentityServer 3(隐式流)进行承载令牌身份验证的所有配置添加为:
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(options =>
{
options.Authority = "https://demo.identity.abc.com/identity/"; // Identity Server 3
options.ApiName = "Test_Api"; // scope
options.LegacyAudienceValidation = true;
});
services.AddMvcCore(options =>
{
// IS3 does not include the api name/audience - hence the extra scope check
options.Filters.Add(new AuthorizeFilter(ScopePolicy.Create("Test_Api")));
})
.AddJsonFormatters()
.AddAuthorization();
services.AddMvc(options =>
{
options.Filters.Add(new Filter1());
}).SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddCors();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseCors(policy =>
{
policy.AllowAnyOrigin();
policy.AllowAnyHeader();
policy.AllowAnyMethod();
});
app.UseAuthentication();
app.UseMvc();
}
我收到详细信息500 Internal Server Error
You must either set Authority or IntrospectionEndpoint
。
在WebApi 2.0中,权限运行正常