Identityserver4 客户机密有什么用?
我们使用EntityFramework核心来存储配置数据。与客户一起存储客户机密有什么用途?或者我们以后可以添加/修改客户机密吗Identityserver4 客户机密有什么用?,identityserver4,Identityserver4,我们使用EntityFramework核心来存储配置数据。与客户一起存储客户机密有什么用途?或者我们以后可以添加/修改客户机密吗 public static IEnumerable<Client> GetClients() { return new List<Client> { new Client { ClientId = "client", // no in
public static IEnumerable<Client> GetClients()
{
return 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" },
AccessTokenLifetime=3600
}
当以编程方式请求令牌时,您将需要密码来访问 例如,您可以使用库:
尽管加文·萨瑟兰的回答解释了如何使用客户机密,但我相信问题更多的是关于它们存在的原因。基本上,可以将客户机ID和客户机密码视为用户名/密码,使特定的客户机应用程序能够使用定义允许哪些请求的其他IdentityServer客户机配置元素启动OpenID Connect请求 您可以更改机密,但在IdentityServer和客户端应用程序之间同步机密是一个手动过程。这与某些密钥轮换场景不同,在这些场景中,您可以在一段时间内激活多个秘密,在所有客户端都更新后删除旧的秘密,如果这是您的想法的话 如果您查看任何OIDC/OAuth2第三方身份提供商Google、Facebook等,它们都通过发布客户端ID和与特定客户端相关的机密来进行操作,通常这意味着特定的域
var client = new TokenClient(
doc.TokenEndpoint,
"client_id",
"secret");
var response = await client.RequestClientCredentialsAsync("scope");
var token = response.AccessToken;