identityserver4 - 使用身份服务器 4 的两因素身份验证

标签 identityserver4

如何使用 Identity Server 4 实现两因素身份验证? token 端点返回一个带有用户名和密码/客户端凭据的 token 。
我们可以自定义这些端点吗?

根据示例的两种方法都不允许自定义端点:

>     var tokenClient = new TokenClient(disco.TokenEndpoint, "ro.client", "secret");
>     var tokenResponse = await tokenClient.RequestResourceOwnerPasswordAsync("brockallen@gmail.com",
> "Pass123$", "api1");

是否可以使用 asp.net 身份或 EF Core 实现来实现 2 因素身份验证?

最佳答案

这根本不应该是问题。当用户被重定向到身份服务器进行登录时,如果启用了 2FA,那么他/她必须在身份服务器返回响应之前输入身份验证器的代码。我已经创建了一个存储库和 blog post series详细解释相关概念。在 AccountController在 IdentityServer 中,您必须检查是否启用了 2FA,并在返回响应之前通过提供身份验证器代码要求用户继续。

var signInResult = await _signInManager.PasswordSignInAsync(model.UserName, model.Password, true,
    lockoutOnFailure: false);

if (signInResult.RequiresTwoFactor)
{
    result.Status = Status.Success;
    result.Message = "Enter the code generated by your authenticator app";
    result.Data = new {requires2FA = true};
    return result;
}


您还需要一个 TwoFactorAuthenticationController支持所有 2FA 任务(启用/禁用 2FA、使用验证码/恢复 token 登录、重置验证器等...)

关于identityserver4 - 使用身份服务器 4 的两因素身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43329907/

相关文章:

c# - IdentityServer 4 对它的工作原理感到困惑

c# - Identityserver4 用户登录后选择账号

c# - 拦截asp.net core Authorize Action 授权成功后执行自定义 Action

c# - IdentityServer4 - 客户端的委托(delegate)访问 token

c# - 使用 ITfoxtec.Identity.Saml2 登录用户

identityserver4 - IdentityServer4 的刷新 token

asp.net-mvc - IdentityServer 4、OpenIdConnect 重定向到外部登录 url

c# - 获取页面已通过 HTTPS 加载,但请求了不安全的 XMLHttpRequest 端点 '.well-known/openid-configuration'

.net - 如何使用 MySQL 设置 Identity Server 4

identityserver4 - 如何为 IdentityServer4 创建共享 key ?