我已经测试了Azure Web App的(身份验证AAD),但它不适用于团队或网络聊天,因为端点不会重定向它.
我有测试来实现AUTH卡,但它不适用于团队.
注意:我正在使用botframework C#api BotBuilder 3.15.2.2
我看其他“问”像:
AAD authentication in Microsoft teams for Bot Framework
Is it possible to access custom tabs in 1:1 chats in MS Teams?
https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/authentication/auth-flow-bot
https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/authentication/auth-bot-AAD
https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/authentication/authentication
此致
帕斯卡尔.
编辑:
我已经实现了Adrian提取的解决方案,下面是一段在MessasController.cs(Post Function)上实现此功能的C#代码:
注意==>添加本地主机使用的访问权限
//https://stackoverflow.com/questions/51090597/botframework-on-teams-channel-11-authentication-aad-integrated string tenantIdAAD = ""; try { tenantIdAAD = activity.GetChannelData<TeamsChannelData>().Tenant.Id; } catch (Exception exception) { tenantIdAAD = ""; } ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); if ([AAD_TenantID].TenantIdAAD.Equals(tenantIdAAD) || activity.ServiceUrl.StartsWith("http://localhost") ) { await Conversation.SendAsync(activity,() => new Dialogs.RootDialog().LogIfException()); } else { await connector.Conversations.ReplyToActivityAsync(activity.CreateReply("Access Denied")); }
@R_403_323@
{
…
“from”:{
“id”:“29:1XJKJMvc5GBtc2JwZq0oj8tHZmzrQgFmB39ATiQWA85gQtHieVkKilBZ9XHoq9j7Zaqt7CZ-NJWi7me2kHTL3Bw”,
“名字”:“Richard Moe”,
“aadObjectId”:“ae361bee-9946-4082-99dc-6994b00ceebb”
},
“channelData”:{
“租户”:{
“id”:“72f988bf-86f1-41af-91ab-2d7cd011db47”
}
}
}
channelData.tenant.id标识用户所属的组织(O365租户),因此您可以查看该组织并拒绝不是您期望的消息.
该消息还具有from.aadObjectId中发件人的AAD对象ID.如果您需要令牌提供给其他服务以便您可以代表用户行事,则上述链接中的身份验证流程非常有用,但如果您需要的只是用户的租户和身份,则该消息可满足您的所有需求.
(在信任消息中的任何信息之前,请先记住authenticate the incoming request.)