【发布时间】:2018-05-19 03:54:47
【问题描述】:
我有一个 REST Web 服务,我们可以部署 n 个客户端。部署了相同的应用程序,只是配置不同。我们有一个与这些 REST Web 服务实例对话的 Web 前端网站。用户使用 IdentityServer4 对实例进行身份验证,使用前端调用后端 Web 服务实例,并将令牌传递给它。
我需要防止检索到的授予 webservice-X 访问权限的令牌用于访问 webservice-Y。理想情况下,我会为每个部署的具有相同范围的客户端定义一个 ApiResource。尝试进行身份验证时收到以下错误消息:
发现重复的 API 范围。这是一个无效的配置。对 API 范围使用不同的名称。找到的范围:PaymentApi、DocumentApi
有没有办法可以禁用此重复检查?是否有另一种方法来配置所有内容来完成此操作?
我的部分配置:
new ApiResource
{
Name = "WebService-X",
DisplayName = "WebService-X",
Description = "Client Api residing on customer-X network",
Enabled = true,
Scopes = new List<Scope>()
{
new Scope()
{
Name = "PaymentApi",
DisplayName = "PaymentApi",
ShowInDiscoveryDocument = true,
},
new Scope()
{
Name = "DocumentApi",
DisplayName = "DocumentApi",
ShowInDiscoveryDocument = true,
}
},
ApiSecrets = new List<Secret>
{
new Secret("fdzxGSDFHY)GSFD*U)DIS:LGJSLKFDJGG".Sha256())
},
},
new ApiResource
{
Name = "WebService-Y",
DisplayName = "WebService-Y",
Description = "Client Api residing on customer-Y network",
Enabled = true,
Scopes = new List<Scope>()
{
new Scope()
{
Name = "PaymentApi",
DisplayName = "PaymentApi",
ShowInDiscoveryDocument = true,
},
new Scope()
{
Name = "DocumentApi",
DisplayName = "DocumentApi",
ShowInDiscoveryDocument = true,
}
},
ApiSecrets = new List<Secret>
{
new Secret("fdzxGSDFHY)GSDFS$#%#$LKFDJGG".Sha256())
},
},
我想避免这样的事情,因为它不能很好地扩展:
new ApiResource
{
Name = "WebService-X",
DisplayName = "WebService-X",
Description = "Client Api residing on customer-X network",
Enabled = true,
Scopes = new List<Scope>()
{
new Scope()
{
Name = "PaymentApi-X",
DisplayName = "PaymentApi-X",
ShowInDiscoveryDocument = true,
},
new Scope()
{
Name = "DocumentApi-X",
DisplayName = "DocumentApi-X",
ShowInDiscoveryDocument = true,
}
},
ApiSecrets = new List<Secret>
{
new Secret("fdzxGSDFHY)GSFD*U)DIS:LGJSLKFDJGG".Sha256())
},
},
new ApiResource
{
Name = "WebService-Y",
DisplayName = "WebService-Y",
Description = "Client Api residing on customer-Y network",
Enabled = true,
Scopes = new List<Scope>()
{
new Scope()
{
Name = "PaymentApi-Y",
DisplayName = "PaymentApi-Y",
ShowInDiscoveryDocument = true,
},
new Scope()
{
Name = "DocumentApi-Y",
DisplayName = "DocumentApi-Y",
ShowInDiscoveryDocument = true,
}
},
ApiSecrets = new List<Secret>
{
new Secret("fdzxGSDFHY)GSDFS$#%#$LKFDJGG".Sha256())
},
},
【问题讨论】:
-
范围必须有唯一的名称。
标签: asp.net-core identityserver4