Azure B2C Graph API:为用户错误登录尝试设置帐户锁定

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

有没有办法通过从代码库发送 API 调用来锁定 Azure B2C 帐户?我需要编写一个函数来满足以下要求

使用错误密码尝试登录 3 次失败后,帐户应被锁定,直到用户解锁。它应该被锁定一段规定的时间。

public async Task<string> LockUserAccount(string api, string query)
{

  AuthenticationResult result = authContext.AcquireToken("https://graph.windows.net", credential);


  HttpClient http = new HttpClient();


        **Here I need your help what kind of URL do i need to call here**
        > // string url = "https://graph.windows.net/" + tenant + api + "?" +

        >    
        >    //HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url);

     request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken);
     HttpResponseMessage response = await http.SendAsync(request);

        if (!response.IsSuccessStatusCode)
            {
               string error = await response.Content.ReadAsStringAsync();
               object formatted = JsonConvert.DeserializeObject(error);
               throw new WebException("Error Calling the Graph API: \n" + JsonConvert.SerializeObject(formatted, Formatting.Indented));
            }

    return await response.Content.ReadAsStringAsync();
}

我已经阅读了此文档,它说在进一步失败的登录尝试后锁定间隔会增加:https://learn.microsoft.com/en-us/azure/active-directory/authentication/howto-password-smart-锁定#manage-azure-ad-smart-lockout-values

c# azure asp.net-web-api azure-ad-b2c azure-ad-graph-api
2个回答
0
投票

似乎没有相关的api来锁定用户指定的时间。

您还可以向 Azure 团队提供反馈

我的解决方法是我们可以计算尝试次数。如果 3 次登录尝试失败,则将用户信息发送到 servicebus 预定消息。然后更新用户设置

accountEnabled
false

之后我们可以使用Azure功能服务总线触发器来更新用户设置

accountEnabled
true


0
投票

为什么不能使用智能锁? 它正是为此而设计的 https://learn.microsoft.com/en-us/azure/active-directory-b2c/threat-management

© www.soinside.com 2019 - 2024. All rights reserved.