我正在尝试让Identity Server 4使用智能卡根据用户提供的客户端证书来发行令牌。我创建了一个新客户端以及SecretParser
和SecretValidator
。为什么Identity Server希望我在客户定义中对机密进行硬编码。没有秘密对那里的硬代码有意义。我问的原因是,除非我在客户端中输入了伪造的秘密,否则我的SecretValidator
永远不会运行。如果未提供,我只会收到一条消息,说Invalid Client
。
使用Identity Server 4验证客户端证书的正确方法是什么?我在“相互TLS”部分中找到的文档似乎无法说明全部情况,并且提供了示例客户端,其中包含硬编码的机密。
在IdentityServer上声明客户端时,可以禁用对密码的需要。只需将RequireClientSecret设置为false。
这里是一个例子:
new Client
{
ClientId = "js",
ClientName = "JavaScript Client",
AllowedGrantTypes = GrantTypes.Code,
RequirePkce = true,
RequireClientSecret = false, // This disables the need for a secret
RedirectUris = { "https://localhost:5003/callback.html" },
PostLogoutRedirectUris = { "https://localhost:5003/index.html" },
AllowedCorsOrigins = { "https://localhost:5003" },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"api1"
}
}