Postgresql 无法在Identity Server中对用户进行身份验证

Postgresql 无法在Identity Server中对用户进行身份验证,postgresql,asp.net-core,asp.net-identity,identityserver4,Postgresql,Asp.net Core,Asp.net Identity,Identityserver4,我正在尝试通过/connect/token端点对Identity Server 4中的用户进行身份验证。我正在填写邮递员的所有必填字段: grant_类型 用户名 暗语 客户识别码 客户机密 我总是得到无效的客户响应 我已在下表中插入了值: 网络用户 客户 客户格兰特类型 客户秘密 对于PasswordHash列中的表AspNetUsers,我添加了用SHA256哈希的哈希密码。在ClientGrantTypes中,我添加了值为“password”的GrantType,并插入了正确的Client

我正在尝试通过/connect/token端点对Identity Server 4中的用户进行身份验证。我正在填写邮递员的所有必填字段:

grant_类型 用户名 暗语 客户识别码 客户机密 我总是得到无效的客户响应

我已在下表中插入了值:

网络用户 客户 客户格兰特类型 客户秘密 对于PasswordHash列中的表AspNetUsers,我添加了用SHA256哈希的哈希密码。在ClientGrantTypes中,我添加了值为“password”的GrantType,并插入了正确的ClientId

以下是我的ConfigureServices的外观:

public void ConfigureServices(IServiceCollection services)
{
    string connectionString = "Server=192.168.1.108; Port=5432; Database=Users; User Id=postgres;Password=RandomPassword123";
    var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;

    services.AddIdentityServer()
        .AddConfigurationStore(options =>
        {
            options.ConfigureDbContext = builder =>
            {
                builder.UseNpgsql(connectionString, action =>
                {
                    action.MigrationsAssembly(migrationsAssembly);
                });
            };
        })
        .AddAspNetIdentity<Users>().AddConfigurationStore(options=>
        {
            options.ConfigureDbContext = builder =>
            {
                builder.UseNpgsql(connectionString, action =>
                {
                    action.MigrationsAssembly(migrationsAssembly);
                });
            };
        }).AddDeveloperSigningCredential();


    services.AddEntityFrameworkNpgsql();
    services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
我正在努力找出我做错了什么,所以任何帮助都将不胜感激

编辑:

我已经包括了日志记录。这是我在《邮递员》中的截图:

这是Identity Server的完整日志:

[21:25:46调试]IdentityServer4.Hosting.EndpointRouter请求路径 /连接/令牌与端点类型令牌匹配

[21:25:46调试]IdentityServer4.Hosting.EndpointRouter端点 已启用:令牌,已成功创建处理程序: IdentityServer4.Endpoints.TokenEndpoint

[21:25:46信息] IdentityServer4.Hosting.IdentityServer中间件调用 IdentityServer端点:的IdentityServer 4.Endpoints.TokenEndpoint /连接/令牌

[21:25:46调试]IdentityServer4.Endpoints.TokenEndpoint启动令牌 请求

[21:25:46调试]IdentityServer4.Validation.ClientSecretValidator 启动客户端验证

[21:25:46调试] IdentityServer4.Validation.BasicAuthenticationSecretParser启动 解析基本身份验证密钥

[21:25:46调试]发现IdentityServer4.Validation.SecretParser解析器 秘密:BasicAuthenticationSecretParser

[21:25:46调试]IdentityServer4.Validation.SecretParser机密id 发现:琉球

[21:25:46调试]IdentityServer4.EntityFramework.Stores.ClientStore 在数据库中找到Ryukote:False

[21:25:46错误]IdentityServer4.Validation.ClientSecretValidator编号 找到id为“Ryukote”的客户端。流产

日志让我困惑,因为有些东西是不真实的。这可以通过查看我提供的Postman屏幕截图来确认。

错误来自BasicAuthenticationSecretParser,因此我认为您对令牌端点的请求中可能有一个基本授权标头,其中包含

Authorization: Basic Ryukote:password
这就是IdentityServer从中获取客户端id“Ryukote”的地方


从您的请求中删除授权标头。

Identity service的控制台输出\日志文件服务将为您提供有关客户端无效原因的详细信息。谢谢。我已经包括了日志,我得到了一个奇怪的日志。我会将日志和我在Postman中的内容粘贴到原始帖子中。是的,但我仍然有无效的客户端错误,但这次的日志输出不同。[17:38:39调试]IdentityServer4.Validation.HashedSharedSecretValidator未为客户端配置共享密钥。[17:38:39调试]IdentityServer4.Validation.SecretValidator机密验证程序无法验证客户端的机密[17:38:39错误]IdentityServer4.Validation.ClientSecretValidator客户端机密验证失败:randomclient。错误为客户端未配置共享机密。您是否为客户端配置了共享密钥?您可以将客户端配置添加到问题中吗?该SHA256值在纯文本中是机密的。它指向一个ClientId 1,我也定义了这个ClientId,它是randomclient。