简体   繁体   English

如何为 IdentityServer4 创建一个 client_secret?

[英]How to create a client_secret for IdentityServer4?

I am creating an Authentication Server using IdentityServer4.我正在使用 IdentityServer4 创建一个身份验证服务器。

I am creating a client that will be accessed using Resource Owner Password Credentials.我正在创建一个将使用资源所有者密码凭据访问的客户端。

But I am wondering what should be the client_id and client_secret.但我想知道 client_id 和 client_secret 应该是什么。

Should the client_id be a human-readable name of the client for eg app name or it should be a random number or string? client_id 应该是客户端的人类可读名称,例如应用程序名称,还是应该是随机数或字符串?

The client_secret is a string but what should be its value? client_secret 是一个字符串,但它的值应该是什么? A UUID?一个UUID? a random string?一个随机字符串? base64 string? base64 字符串?

I went through IdentityServer4 and OpenId documentation but could not find any guidance.我浏览了 IdentityServer4 和 OpenId 文档,但找不到任何指导。

Here's the example they have provided in their docs.这是他们在文档中提供的示例。

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" }
}

As you can see in the example, they have set up a human-friendly client_id.正如您在示例中看到的,他们设置了一个人性化的 client_id。

  • client_id: is a public identifier for each client. client_id:是每个客户端的公共标识符。 It must be unique across all clients that the authorization server handles.它在授权服务器处理的所有客户端中必须是唯一的。 It is public but better not to be guessable by third parties.它是公开的,但最好不要被第三方猜测。 Examples:例子:
Github: 6779ef20e75817b79602
Google: 292085223830.apps.googleusercontent.com
Instagram: f2a1ed52710d4533bde25be6da03b6e3
Windows Live: 00000000400ECB04
  • client_secret: is just known by client and authorization server. client_secret:客户端和授权服务器才知道。 It must be random to not be guessable.它必须是随机的,不可猜测。 Best way to generate is to use a cryptographically secure libraries.生成的最佳方法是使用加密安全库。 You should avoid using common UUID libraries.您应该避免使用常见的 UUID 库。

Read more about secrets for IdentityServer4 here 在此处阅读有关 IdentityServer4 机密的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IdentityServer4 + MVC 客户端在 Docker - IdentityServer4 + MVC client in Docker Microsoft Graph:如何在客户端凭据流中使用证书获取访问令牌? (而不是使用 client_secret) - Microsoft Graph: How to get access token with certificate in client credentials flow? (instead of using a client_secret) IdentityServer4分别对每个客户端进行身份验证 - IdentityServer4 authenticate each client separately IdentityServer4客户端 - 刷新CookieAuthenticationEvents上的访问令牌 - IdentityServer4 client - Refreshing access tokens on CookieAuthenticationEvents IdentityServer4 {“错误”:“无效客户端”} - IdentityServer4 {“error”:“invalid_client”} 如何以编程方式生成gcloud项目oauth信任client_secret json文件 - How to generate gcloud project oauth creds client_secret json file programmatically 自动获取Google API Client_ID和Client_Secret - Get Google API Client_ID and Client_Secret automatically 在Oauth2中哪里存储client_id和client_secret? - Where to store client_id and client_secret in Oauth2? IdentityServer4:我可以在 IdentityServer 中将 PKCE 与客户端凭据一起使用吗? - IdentityServer4: Can I use PKCE with Client Credentials in IdentityServer? Azure:将角色添加到应用注册的 client_secret - Azure : Add a role to a client_secret for an App Registrations
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM