Skip to content

Commit

Permalink
Company Communicator v4 (#276)
Browse files Browse the repository at this point in the history
Included changes:
- Split user and author functionality into different bots. With this change, the authors and users app packages now have different bot IDs, which enables you to use app permission policies to control access to the authors app. (In previous versions, using app permission policies with Company Communicator led to intermittent message delivery failures.)
- Include a Powershell script for deployment and upgrade from v3. The script checks for deployment prerequisites, creates and configures AAD applications, and deploys the resources to your Azure subscription. It can also detect and recover from some Azure deployment failures.
- Set isNotificationOnly to true in the app manifest. This was originally set to false to allow for recovery in case we missed the conversationUpdate activity, but now that we can get the chat thread ID via Graph, we can set this to true.
- Add unit tests for message send and preparation functions
- Bug fixes: #239

Co-authored-by: Anuj Gupta <guptaa@microsoft.com>
Co-authored-by: Priyank Saxena <prsaxen@microsoft.com>
Co-authored-by: Lakshmi Pratap Reddy <v-lareddy@microsoft.com>
Co-authored-by: Ashish Shrivastav <v-ashshr@microsoft.com>
Co-authored-by: Abdelrady Tantawy <v-abtan@microsoft.com>
  • Loading branch information
6 people authored Dec 24, 2020
1 parent 176911e commit f75139d
Show file tree
Hide file tree
Showing 167 changed files with 7,045 additions and 743 deletions.
31 changes: 31 additions & 0 deletions Deployment/AadAppManifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[
{
"resourceAppId": "00000003-0000-0000-c000-000000000000",
"resourceAccess": [
{
"id": "5f8c59db-677d-491f-a6b8-5f174b11ec1d",
"type": "Scope"
},
{
"id": "e1fe6dd8-ba31-4d61-89e7-88639da4683d",
"type": "Scope"
},
{
"id": "88e58d74-d3df-44f3-ad47-e89edf4472e4",
"type": "Scope"
},
{
"id": "5b567255-7703-4780-807c-7be8301ae99b",
"type": "Role"
},
{
"id": "df021288-bdef-4463-88db-98f22de89214",
"type": "Role"
},
{
"id": "74ef0291-ca83-4d02-8c7e-d2391e6a444f",
"type": "Role"
}
]
}
]
12 changes: 12 additions & 0 deletions Deployment/AadOptionalClaims.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"idToken": [],
"accessToken": [
{
"name": "upn",
"source": null,
"essential": false,
"additionalProperties": []
}
],
"saml2Token": []
}
5 changes: 5 additions & 0 deletions Deployment/AadOptionalClaims_Reset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"idToken": [],
"accessToken": [],
"saml2Token": []
}
153 changes: 118 additions & 35 deletions Deployment/azuredeploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,34 @@
"description": "The base name to use for the resources that will be provisioned."
}
},
"botClientId": {
"userClientId": {
"type": "string",
"minLength": 36,
"maxLength": 36,
"metadata": {
"description": "The client ID of the bot Azure AD app, e.g., 123e4567-e89b-12d3-a456-426655440000."
"description": "The client ID of the user bot Azure AD app, e.g., 123e4567-e89b-12d3-a456-426655440000."
}
},
"botClientSecret": {
"userClientSecret": {
"type": "securestring",
"minLength": 1,
"metadata": {
"description": "The client secret of the bot Azure AD app."
"description": "The client secret of the user bot Azure AD app."
}
},
"authorClientId": {
"type": "string",
"minLength": 36,
"maxLength": 36,
"metadata": {
"description": "The client ID of the author bot Azure AD app, e.g., 123e4567-e89b-12d3-a456-426655440000."
}
},
"authorClientSecret": {
"type": "securestring",
"minLength": 1,
"metadata": {
"description": "The client secret of the author bot Azure AD app."
}
},
"senderUPNList": {
Expand All @@ -35,7 +50,7 @@
"defaultValue": true,
"type": "Bool",
"metadata": {
"description": "If proactive app installation should be enabled."
"description": "If proactive app installation should be enabled."
}
},
"UserAppExternalId": {
Expand Down Expand Up @@ -157,6 +172,7 @@
},
"variables": {
"botName": "[parameters('baseResourceName')]",
"authorBotName": "[concat(parameters('baseResourceName'), '-author')]",
"botAppName": "[parameters('baseResourceName')]",
"botAppDomain": "[concat(variables('botAppName'), '.azurewebsites.net')]",
"botAppUrl": "[concat('https://', variables('botAppDomain'))]",
Expand All @@ -170,7 +186,7 @@
"serviceBusSendQueueName": "company-communicator-send",
"serviceBusDataQueueName": "company-communicator-data",
"serviceBusPrepareToSendQueueName": "company-communicator-prep",
"serviceBusExportQueueName": "company-communicator-export",
"serviceBusExportQueueName": "company-communicator-export",
"defaultSASKeyName": "RootManageSharedAccessKey",
"authRuleResourceId": "[resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', variables('serviceBusNamespaceName'), variables('defaultSASKeyName'))]",
"sharedSkus": [
Expand All @@ -182,7 +198,7 @@
"useFrontDoor": "[equals(parameters('customDomainOption'), 'Azure Front Door')]",
"frontDoorName": "[parameters('baseResourceName')]",
"frontDoorDomain": "[toLower(concat(variables('frontDoorName'), '.azurefd.net'))]",
"ProactivelyInstallUserApp": "[parameters('ProactivelyInstallUserApp')]",
"ProactivelyInstallUserApp": "[parameters('ProactivelyInstallUserApp')]",
"UserAppExternalId": "[parameters('UserAppExternalId')]",
"i18n:DefaultCulture": "[parameters('DefaultCulture')]",
"i18n:SupportedCultures": "[parameters('SupportedCultures')]"
Expand All @@ -195,9 +211,9 @@
"location": "[parameters('location')]",
"kind": "Storage",
"properties": {
"supportsHttpsTrafficOnly": true,
"allowBlobPublicAccess": false
},
"supportsHttpsTrafficOnly": true,
"allowBlobPublicAccess": false
},
"sku": {
"name": "Standard_LRS"
}
Expand Down Expand Up @@ -270,23 +286,31 @@
},
{
"name": "AzureAd:ClientId",
"value": "[parameters('botClientId')]"
"value": "[parameters('authorClientId')]"
},
{
"name": "AzureAd:ClientSecret",
"value": "[parameters('botClientSecret')]"
"value": "[parameters('authorClientSecret')]"
},
{
"name": "AzureAd:ApplicationIdURI",
"value": "[if(variables('useFrontDoor'), concat('api://', variables('frontDoorDomain')), '')]"
},
{
"name": "MicrosoftAppId",
"value": "[parameters('botClientId')]"
"name": "UserAppId",
"value": "[parameters('userClientId')]"
},
{
"name": "UserAppPassword",
"value": "[parameters('userClientSecret')]"
},
{
"name": "AuthorAppId",
"value": "[parameters('authorClientId')]"
},
{
"name": "MicrosoftAppPassword",
"value": "[parameters('botClientSecret')]"
"name": "AuthorAppPassword",
"value": "[parameters('authorClientSecret')]"
},
{
"name": "StorageAccountConnectionString",
Expand Down Expand Up @@ -372,6 +396,45 @@
"Request_Source": "rest"
}
},
{
"apiVersion": "2018-07-12",
"name": "[variables('authorBotName')]",
"type": "Microsoft.BotService/botServices",
"location": "global",
"sku": {
"name": "F0"
},
"kind": "sdk",
"properties": {
"displayName": "[concat(parameters('appDisplayName'),'-author')]",
"description": "[parameters('appDescription')]",
"iconUrl": "[parameters('appIconUrl')]",
"msaAppId": "[parameters('authorClientId')]",
"endpoint": "[concat(variables('botAppUrl'), '/api/messages/author')]",
"developerAppInsightKey": "[reference(resourceId('Microsoft.Insights/components', variables('appInsightsName')), '2015-05-01').InstrumentationKey]"
},
"resources": [
{
"name": "[concat(variables('authorBotName'), '/MsTeamsChannel')]",
"type": "Microsoft.BotService/botServices/channels",
"apiVersion": "2018-07-12",
"location": "global",
"sku": {
"name": "F0"
},
"properties": {
"channelName": "MsTeamsChannel",
"location": "global",
"properties": {
"isEnabled": true
}
},
"dependsOn": [
"[concat('Microsoft.BotService/botServices/', variables('authorBotName'))]"
]
}
]
},
{
"apiVersion": "2018-07-12",
"name": "[variables('botName')]",
Expand All @@ -385,8 +448,8 @@
"displayName": "[parameters('appDisplayName')]",
"description": "[parameters('appDescription')]",
"iconUrl": "[parameters('appIconUrl')]",
"msaAppId": "[parameters('botClientId')]",
"endpoint": "[concat(variables('botAppUrl'), '/api/messages')]",
"msaAppId": "[parameters('userClientId')]",
"endpoint": "[concat(variables('botAppUrl'), '/api/messages/user')]",
"developerAppInsightKey": "[reference(resourceId('Microsoft.Insights/components', variables('appInsightsName')), '2015-05-01').InstrumentationKey]"
},
"resources": [
Expand Down Expand Up @@ -487,7 +550,7 @@
"enableExpress": false
}
},
{
{
"type": "Queues",
"apiVersion": "2017-04-01",
"name": "[variables('serviceBusExportQueueName')]",
Expand Down Expand Up @@ -578,14 +641,22 @@
"value": "[reference(resourceId('microsoft.insights/components/', variables('appInsightsName')), '2015-05-01').InstrumentationKey]"
},
{
"name": "MicrosoftAppId",
"value": "[parameters('botClientId')]"
"name": "AuthorAppId",
"value": "[parameters('authorClientId')]"
},
{
"name": "AuthorAppPassword",
"value": "[parameters('authorClientSecret')]"
},
{
"name": "UserAppId",
"value": "[parameters('userClientId')]"
},
{
"name": "MicrosoftAppPassword",
"value": "[parameters('botClientSecret')]"
"name": "UserAppPassword",
"value": "[parameters('userClientSecret')]"
},
{
{
"name": "TenantId",
"value": "[parameters('tenantId')]"
},
Expand Down Expand Up @@ -685,12 +756,12 @@
"value": "5"
},
{
"name": "MicrosoftAppId",
"value": "[parameters('botClientId')]"
"name": "UserAppId",
"value": "[parameters('userClientId')]"
},
{
"name": "MicrosoftAppPassword",
"value": "[parameters('botClientSecret')]"
"name": "UserAppPassword",
"value": "[parameters('userClientSecret')]"
},
{
"name": "StorageAccountConnectionString",
Expand Down Expand Up @@ -784,14 +855,22 @@
"value": "[reference(resourceId('microsoft.insights/components/', variables('appInsightsName')), '2015-05-01').InstrumentationKey]"
},
{
"name": "MicrosoftAppId",
"value": "[parameters('botClientId')]"
"name": "AuthorAppId",
"value": "[parameters('authorClientId')]"
},
{
"name": "MicrosoftAppPassword",
"value": "[parameters('botClientSecret')]"
"name": "AuthorAppPassword",
"value": "[parameters('authorClientSecret')]"
},
{
{
"name": "UserAppId",
"value": "[parameters('userClientId')]"
},
{
"name": "UserAppPassword",
"value": "[parameters('userClientSecret')]"
},
{
"name": "CleanUpScheduleTriggerTime",
"value": "30 23 * * *"
},
Expand Down Expand Up @@ -956,9 +1035,13 @@
}
],
"outputs": {
"botId": {
"authorBotId": {
"type": "string",
"value": "[parameters('authorClientId')]"
},
"userBotId": {
"type": "string",
"value": "[parameters('botClientId')]"
"value": "[parameters('userClientId')]"
},
"appDomain": {
"type": "string",
Expand Down
Loading

0 comments on commit f75139d

Please sign in to comment.