我正在尝试将 Ocelot 与 IS4 一起使用 https://ocelot.readthedocs.io/en/latest/features/authentication.html
使用时
public void ConfigureServices(IServiceCollection services)
{
var authenticationProviderKey = "TestKey";
services.AddAuthentication()
.AddJwtBearer(authenticationProviderKey, x =>
{
});
}
并在ocelot.json中使用“TestKey”,启动应用程序时会抛出错误
无法启动 Ocelot,错误为:TestKey、AllowedScopes:[] 是不支持的身份验证提供程序
知道出了什么问题吗?我需要在 IdentityServer 应用程序中进行一些特别的设置吗?
最佳答案
您需要添加选项,例如:
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
// base-address of your identityserver
options.Authority = "https://demo.identityserver.io";
// name of the API resource
options.Audience = "api1";
});
更多信息:http://docs.identityserver.io/en/latest/topics/apis.html#
您还需要将 API 资源添加到您的身份服务器:
new ApiResource("api1", "Some API 1")
参见:
http://docs.identityserver.io/en/latest/topics/resources.html和 http://docs.identityserver.io/en/latest/reference/api_resource.html#refapiresource
关于c# - Identityserver 4 和 Ocelot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54067154/