到目前为止我得到了什么:
在一个项目中,我有一个授权服务器(Identity Server 4),一些(比如两个)受保护的API(Api资源)和一些应该访问Identity Server的可信客户端(自动化,无用户交互)通过反向通道(对吗?)。想象一下,客户端是亚马逊消防电视盒的那种东西。
根据我在过去几周所读到的内容,此方案的合适流程是 OpenID Connect授权代码流。
我的(理论)结构中有什么:
我有两个API资源(每个API版本一个资源)
我还有两个系列的API客户端
Identity Server 4 StartUp.cs配置(到目前为止)
public void ConfigureServices(IServiceCollection services)
{
// configure identity server with in-memory stores, keys, clients and scopes
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddInMemoryApiResources
(
new List<ApiResource>
{
new ApiResource("api.v1", "API v1"),
new ApiResource("api.v2", "API v2")
}
)
.AddInMemoryClients
(
new List<Client>
{
new Client
{
ClientId = "client.v1",
AllowedGrantTypes = GrantTypes.CodeAndClientCredentials,
AllowAccessTokensViaBrowser = false,
ClientSecrets = { new Secret("secret1".Sha256()) },
AllowedScopes = { "api.v1" }
},
new Client
{
ClientId = "client.v2",
AllowedGrantTypes = GrantTypes.CodeAndClientCredentials,
AllowAccessTokensViaBrowser = false,
ClientSecrets = { new Secret("secret2".Sha256()) },
AllowedScopes = { "api.v1", "api.v2" }
}
}
);
}
我正在努力解决的理论是授权代码部分。
我想让每个客户端实例(再次想象它作为一个小盒子)使用不同的授权代码,允许一个实例访问但拒绝另一个实例访问。
是否打算使用授权码?
我无法理解的一件重要事情:CodeAndClientCredentials定义了两种授权类型。这是否意味着连接需要(代码 AND 客户端凭据),或者它是其中一个定义(代码 OR 客户端凭据)。
我正在努力解决的Identity Server 4代码是:
在定义客户端的代码中,我只能找到AuthorizationCodeLifetime,但没有字段来设置授权代码本身。
似乎我可以定义一个客户机密列表。
ClientSecrets = { new Secret("secret1".Sha256()) },
这是否意味着一个客户端ID可以使用多个秘密?不同的客户机密是否更适合我的#34;允许一个人否认另一个&#34;问题
好的,我已经重新阅读了,现在我得到了它(至少多了一点):客户端发送的授权代码没有定义,但客户端收到了授权代码。
授权代码流返回授权代码(就像在锡上所说的那样),然后可以将其交换为身份令牌和/或访问令牌。这需要使用客户端ID和密码进行客户端身份验证,以从后端检索令牌
但是,如何配置我的Identity Server以允许一个实例并拒绝另一个实例。
使用不同的客户机密?使用extension grants?