IdentityServer4 ClientCredentials基本问题(我认为)
IdentityServer4 ClientCredentials basic question (I think)
这可能是一个关于 IdentityServer4 的基本问题
所以我正在研究 identityserver4 文档
我完成了
[使用客户端凭证保护 API] https://docs.identityserver.io/en/latest/quickstarts/1_client_credentials.html#
我明白了,所以我设置了一个 APi 具有 Api 范围 (api1) 的资源,我的“客户端”使用客户端凭据和该范围
public static IEnumerable<Client> Clients =>
new List<Client>
{
new Client
{
ClientId = "client",
// no interactive user, use the clientid/secret for authentication
AllowedGrantTypes = GrantTypes.ClientCredentials,
// secret for authentication
ClientSecrets =
{
new Secret("secret".Sha256())
},
// scopes that client has access to
AllowedScopes = { "api1" }
}
};
好的,那么我将进行下一节“使用 ASP.NET 核心的交互式应用程序”
我明白了
所以我的客户需要两者都做,很高兴有下一节
“ASP.NET 核心和 API 访问权限”- 将它们放在一起,也就是说我所要做的就是
new Client
{
ClientId = "mvc",
ClientSecrets = { new Secret("secret".Sha256()) },
AllowedGrantTypes = GrantTypes.Code,
// where to redirect to after login
RedirectUris = { "https://localhost:5002/signin-oidc" },
// where to redirect to after logout
PostLogoutRedirectUris = { "https://localhost:5002/signout-callback-oidc" },
AllowOfflineAccess = true,
AllowedScopes = new List<string>
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"api1"
}
}
哪个有效
我不明白的是 - IdentityServer4 客户端“客户端”具有
AllowedGrantTypes = GrantTypes.ClientCredentials
那么“mvc”客户端如何只需要将“api1”添加到允许的范围来获取客户端凭据?
我在文档中看不到解释
按照惯例“客户端凭证”是不记名令牌(所以我不再需要客户端“客户端”)?还是 IdentityServer4 以某种方式 link 客户端基于它们都具有 api1 范围的事实?
谢谢
ClientCredentials,用于service-to-service通信。也许您有一项后台工作需要与 API 交谈。对于一个 API 与另一个 API.
交谈
授权代码流通常用于 MVC 应用程序,在该应用程序中,您有一个用户登录该站点,您会取回一个访问令牌,然后您可以将其发送给给定的 API,例如 API1 在这种情况下。
在您的场景中,您实际上不需要同时使用两者。对于以api1为范围的public面向服务器,仅授权代码流就足够了。
当您与 API.
交谈时,您在两个流程中都使用了不记名令牌(授权 header)
这可能是一个关于 IdentityServer4 的基本问题
所以我正在研究 identityserver4 文档 我完成了
[使用客户端凭证保护 API] https://docs.identityserver.io/en/latest/quickstarts/1_client_credentials.html#
我明白了,所以我设置了一个 APi 具有 Api 范围 (api1) 的资源,我的“客户端”使用客户端凭据和该范围
public static IEnumerable<Client> Clients =>
new List<Client>
{
new Client
{
ClientId = "client",
// no interactive user, use the clientid/secret for authentication
AllowedGrantTypes = GrantTypes.ClientCredentials,
// secret for authentication
ClientSecrets =
{
new Secret("secret".Sha256())
},
// scopes that client has access to
AllowedScopes = { "api1" }
}
};
好的,那么我将进行下一节“使用 ASP.NET 核心的交互式应用程序” 我明白了
所以我的客户需要两者都做,很高兴有下一节 “ASP.NET 核心和 API 访问权限”- 将它们放在一起,也就是说我所要做的就是
new Client
{
ClientId = "mvc",
ClientSecrets = { new Secret("secret".Sha256()) },
AllowedGrantTypes = GrantTypes.Code,
// where to redirect to after login
RedirectUris = { "https://localhost:5002/signin-oidc" },
// where to redirect to after logout
PostLogoutRedirectUris = { "https://localhost:5002/signout-callback-oidc" },
AllowOfflineAccess = true,
AllowedScopes = new List<string>
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"api1"
}
}
哪个有效
我不明白的是 - IdentityServer4 客户端“客户端”具有
AllowedGrantTypes = GrantTypes.ClientCredentials
那么“mvc”客户端如何只需要将“api1”添加到允许的范围来获取客户端凭据?
我在文档中看不到解释
按照惯例“客户端凭证”是不记名令牌(所以我不再需要客户端“客户端”)?还是 IdentityServer4 以某种方式 link 客户端基于它们都具有 api1 范围的事实?
谢谢
ClientCredentials,用于service-to-service通信。也许您有一项后台工作需要与 API 交谈。对于一个 API 与另一个 API.
交谈授权代码流通常用于 MVC 应用程序,在该应用程序中,您有一个用户登录该站点,您会取回一个访问令牌,然后您可以将其发送给给定的 API,例如 API1 在这种情况下。
在您的场景中,您实际上不需要同时使用两者。对于以api1为范围的public面向服务器,仅授权代码流就足够了。
当您与 API.
交谈时,您在两个流程中都使用了不记名令牌(授权 header)