【发布时间】:2021-02-25 11:30:11
【问题描述】:
这可能是关于 IdentityServer4 的一个基本问题
所以我正在研究 identityserver4 文档 我已经完成了
[使用客户端凭据保护 API]https://docs.identityserver.io/en/latest/quickstarts/1_client_credentials.html#
我明白了,所以我设置了一个带有 Api 范围 (api1) 的 APi 资源,我的“客户端”使用客户端凭据和该范围
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 Core 的交互式应用程序” 我明白了
所以我的客户需要同时做这两件事,所以很高兴有下一部分 “ASP.NET Core 和 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 是否基于它们都具有 api1 范围的事实以某种方式链接客户端?
谢谢
【问题讨论】:
标签: c# asp.net-mvc identityserver4