使用自定义SecretParser / Validator的Identity Server 4客户端证书身份验证

问题描述 投票:0回答:1

我正在尝试让Identity Server 4使用智能卡根据用户提供的客户端证书来发行令牌。我创建了一个新客户端以及SecretParserSecretValidator。为什么Identity Server希望我在客户定义中对机密进行硬编码。没有秘密对那里的硬代码有意义。我问的原因是,除非我在客户端中输入了伪造的秘密,否则我的SecretValidator永远不会运行。如果未提供,我只会收到一条消息,说Invalid Client

使用Identity Server 4验证客户端证书的正确方法是什么?我在“相互TLS”部分中找到的文档似乎无法说明全部情况,并且提供了示例客户端,其中包含硬编码的机密。

asp.net-core identityserver4
1个回答
0
投票

在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"
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.