将团队机器人限制在我的组织中

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

我正在使用MSFT Bot Framework来构建团队机器人,但我的机器人只与我的组织相关。实际上我不希望组织外的任何人能够与之交谈。

我一直在寻找如何将我的机器人限制到特定的Office 365组织,但无法找到如何做到这一点。我唯一能找到的是使用其他方用户字符串来查看他们居住的组织。

我的问题:有没有办法将我的机器人限制在一个O365组织?

谢谢

布拉姆

microsoft-teams
2个回答
1
投票

它已经2年但没有真正的答案,它出现在我的相关清单中......

这些天你可以编写一个简单的中间件来进行租户过滤,如下所示:

public static string TenantFilterSettingAny = "#ANY#";

/// <summary>
/// Here are below scenarios - 
///     #Scenario 1 - Reject the Bot If Tenant is configured in web.config and doesn't match with Incoming request tenant
///     #Scenario 2 - Allow Bot for every Tenant if Tenant is not configured in web.config file and default value is #ANY#             
/// </summary>
/// <param name="activity"></param>
/// <param name="currentTenant"></param>
/// <returns></returns>
public static bool RejectMessageBasedOnTenant(IMessageActivity activity, string currentTenant)
{
    if (!String.Equals(ConfigurationManager.AppSettings["OFFICE_365_TENANT_FILTER"], TenantFilterSettingAny))
    {
        //#Scenario 1
        return !string.Equals(ConfigurationManager.AppSettings["OFFICE_365_TENANT_FILTER"], currentTenant);
    }
    else
    {
        //Scenario 2
        return false;
    }
}

它取自this sample


0
投票

现在最可靠的方法是实现用户身份验证,如AuthBot中所示,然后检查登录用户的tenant-id。

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