Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core 在隐式流中验证IdentityServer4中的用户名和密码_Asp.net Core_Identityserver4 - Fatal编程技术网

Asp.net core 在隐式流中验证IdentityServer4中的用户名和密码

Asp.net core 在隐式流中验证IdentityServer4中的用户名和密码,asp.net-core,identityserver4,Asp.net Core,Identityserver4,如何在隐式流中验证用户名和密码?我尝试添加一个自定义IResourceOwnerPasswordValidatorvalidator,但在那里设置断点时没有调用它: services.AddIdentityServer() .AddDeveloperSigningCredential() .AddInMemoryApiResources(Config.GetApiResources()) .AddInMemoryClients(Config.GetClients())

如何在
隐式
流中验证用户名和密码?我尝试添加一个自定义
IResourceOwnerPasswordValidator
validator,但在那里设置断点时没有调用它:

services.AddIdentityServer()
    .AddDeveloperSigningCredential()
    .AddInMemoryApiResources(Config.GetApiResources())
    .AddInMemoryClients(Config.GetClients())
    .AddInMemoryIdentityResources(Config.GetIdentityResources())

    .AddResourceOwnerValidator<ResourceOwnerPasswordValidator>();
    ;
当我查看IdentityServer4的源代码时,在类
TokenRequestValidator
中,似乎
IResourceOwnerPasswordValidator
validator只在
密码流中被调用

当我试图添加
IExtensionGrantValidator
,它是默认的验证器(包括
隐式
),它也没有被调用


如何在
隐式
流中验证用户名和密码?

我刚刚找到了解决方案,用户名/密码验证不是授权流的一部分,它直接在登录页面的控制器中完成,在示例7中,它在
AccountController
中完成

if (ModelState.IsValid)
{
    // validate username/password against in-memory store
    if (_users.ValidateCredentials(model.Username, model.Password))
    {
        ...
    }
用针对真实用户存储而不是默认的
TestUserStore
的验证来替换这段代码就足够了

if (ModelState.IsValid)
{
    // validate username/password against in-memory store
    if (_users.ValidateCredentials(model.Username, model.Password))
    {
        ...
    }