Skip to content

Commit

Permalink
CC v5.4 changes (#1028)
Browse files Browse the repository at this point in the history
* CC v5.4 changes
  • Loading branch information
v-royavinash authored May 10, 2023
1 parent c3ccabe commit 229c711
Show file tree
Hide file tree
Showing 56 changed files with 2,309 additions and 232 deletions.
1,419 changes: 1,419 additions & 0 deletions Deployment/GCCH/azuredeploy.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Deployment/azuredeploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@
"UserAppSecretResourceId": "[resourceId(resourceGroup().name, 'Microsoft.KeyVault/vaults/secrets', variables('keyVaultName'), variables('UserAppSecretName'))]",
"AuthorAppSecretResourceId": "[resourceId(resourceGroup().name, 'Microsoft.KeyVault/vaults/secrets', variables('keyVaultName'), variables('AuthorAppSecretName'))]",
"GraphAppSecretResourceId": "[resourceId(resourceGroup().name, 'Microsoft.KeyVault/vaults/secrets', variables('keyVaultName'), variables('GraphAppSecretName'))]",
"netFrameworkVersion":"v6.0"
"netFrameworkVersion": "v6.0"
},
"resources": [
{
Expand Down Expand Up @@ -633,6 +633,7 @@
"WEBSITE_LOAD_CERTIFICATES": "*",
"APPINSIGHTS_INSTRUMENTATIONKEY": "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('AppInsightsSecretResourceId'), '2015-06-01').secretUriWithVersion, ')')]",
"WEBSITE_NODE_DEFAULT_VERSION": "16.13.0",
"WEBSITE_NPM_DEFAULT_VERSION": "8.19.2",
"KeyVault:Url": "[variables('keyVaultUrl')]",
"DOTNET_ADD_GLOBAL_TOOLS_TO_PATH": "false",
"REACT_APP_HEADERTEXT": "[parameters('headerText')]",
Expand Down
1 change: 1 addition & 0 deletions Deployment/azuredeploywithcert.json
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@
"WEBSITE_LOAD_CERTIFICATES": "*",
"APPINSIGHTS_INSTRUMENTATIONKEY": "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('AppInsightsSecretResourceId'), '2015-06-01').secretUriWithVersion, ')')]",
"WEBSITE_NODE_DEFAULT_VERSION": "16.13.0",
"WEBSITE_NPM_DEFAULT_VERSION": "8.19.2",
"KeyVault:Url": "[variables('keyVaultUrl')]",
"DOTNET_ADD_GLOBAL_TOOLS_TO_PATH": "false",
"REACT_APP_HEADERTEXT": "[parameters('headerText')]",
Expand Down
2 changes: 1 addition & 1 deletion Manifest/manifest_authors.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.5/MicrosoftTeams.schema.json",
"manifestVersion": "1.5",
"version": "5.3.0",
"version": "5.4.0",
"id": "1c07cd26-a088-4db8-8928-ace382fa219f",
"packageName": "com.microsoft.teams.companycommunicator.authors",
"developer": {
Expand Down
2 changes: 1 addition & 1 deletion Manifest/manifest_users.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.5/MicrosoftTeams.schema.json",
"manifestVersion": "1.5",
"version": "5.3.0",
"version": "5.4.0",
"id": "148a66bb-e83d-425a-927d-09f4299a9274",
"packageName": "com.microsoft.teams.companycommunicator",
"developer": {
Expand Down
54 changes: 54 additions & 0 deletions Source/CompanyCommunicator.Common/Adapter/CCBotAdapter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// <copyright file="CCBotAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// </copyright>

namespace Microsoft.Teams.Apps.CompanyCommunicator.Common.Adapter
{
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Connector.Authentication;
using Microsoft.Bot.Schema;
using Microsoft.Teams.Apps.CompanyCommunicator.Common.Secrets;

/// <summary>
/// Bot framework http adapter instance.
/// </summary>
public class CCBotAdapter : CCBotAdapterBase
{
private readonly ICertificateProvider certificateProvider;

/// <summary>
/// Initializes a new instance of the <see cref="CCBotAdapter"/> class.
/// </summary>
/// <param name="botFrameworkAuthentication">credential provider.</param>
public CCBotAdapter(
ICertificateProvider certificateProvider,
BotFrameworkAuthentication botFrameworkAuthentication)
: base(botFrameworkAuthentication)
{
this.certificateProvider = certificateProvider;
}

/// <inheritdoc/>
public override async Task CreateConversationUsingCertificateAsync(string channelId, string serviceUrl, AppCredentials appCredentials, ConversationParameters conversationParameters, BotCallbackHandler callback, CancellationToken cancellationToken)
{
var cert = await this.certificateProvider.GetCertificateAsync(appCredentials.MicrosoftAppId);
var options = new CertificateAppCredentialsOptions()
{
AppId = appCredentials.MicrosoftAppId,
ClientCertificate = cert,
};

await this.CreateConversationAsync(appCredentials.MicrosoftAppId, channelId, serviceUrl, null/*audience*/, conversationParameters, callback, cancellationToken);
}

/// <inheritdoc/>
public override async Task CreateConversationUsingSecretAsync(string channelId, string serviceUrl, MicrosoftAppCredentials credentials, ConversationParameters conversationParameters, BotCallbackHandler callback, CancellationToken cancellationToken)
{
await this.CreateConversationAsync(credentials.MicrosoftAppId, channelId, serviceUrl, null/*audience*/, conversationParameters, callback, cancellationToken);
}
}
}
56 changes: 56 additions & 0 deletions Source/CompanyCommunicator.Common/Adapter/CCBotAdapterBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// <copyright file="CCBotAdapterBase.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// </copyright>

namespace Microsoft.Teams.Apps.CompanyCommunicator.Common.Adapter
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using Microsoft.Bot.Connector.Authentication;
using Microsoft.Bot.Schema;
using Microsoft.Extensions.Logging;

/// <summary>
/// Bot Framework Http Adapter interface.
/// </summary>
public abstract class CCBotAdapterBase : CloudAdapter
{
/// <summary>
/// Initializes a new instance of the <see cref="CCBotAdapterBase"/> class.
/// </summary>
/// <param name="botFrameworkAuthentication">Bot Framework Authentication.</param>
/// <param name="logger">Logger</param>
protected CCBotAdapterBase(BotFrameworkAuthentication botFrameworkAuthentication, ILogger logger = null)
: base(botFrameworkAuthentication, logger)
{
}

/// <summary>
/// Creates a conversation using app secret on the specified channel.
/// </summary>
/// <param name="channelId">The ID for the channel.</param>
/// <param name="serviceUrl">The channel's service URL endpoint.</param>
/// <param name="credentials">The application credentials for the bot.</param>
/// <param name="conversationParameters">The conversation information to use to create the conversation.</param>
/// <param name="callback">The method to call for the resulting bot turn.</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>A task that represents the work queued to execute.</returns>
public abstract Task CreateConversationUsingSecretAsync(string channelId, string serviceUrl, MicrosoftAppCredentials credentials, ConversationParameters conversationParameters, BotCallbackHandler callback, CancellationToken cancellationToken);

/// <summary>
/// Creates a conversation using app certificate on the specified channel.
/// This method can be used to use certificates for authentication.
/// </summary>
/// <param name="channelId">The ID for the channel.</param>
/// <param name="serviceUrl">The channel's service URL endpoint.</param>
/// <param name="appCredentials">The application credentials for the bot.</param>
/// <param name="conversationParameters">The conversation information to use to create the conversation.</param>
/// <param name="callback">The method to call for the resulting bot turn.</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>A task that represents the work queued to execute.</returns>
public abstract Task CreateConversationUsingCertificateAsync(string channelId, string serviceUrl, AppCredentials appCredentials, ConversationParameters conversationParameters, BotCallbackHandler callback, CancellationToken cancellationToken);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace Microsoft.Teams.Apps.CompanyCommunicator.Common.Configuration
{
/// <summary>
/// App configuration for commercial environment.
/// </summary>
public class CommericalConfiguration : IAppConfiguration
{
private readonly string tenantId;

/// <summary>
/// Initializes a new instance of the <see cref="CommericalConfiguration"/> class.
/// </summary>
/// <param name="tenantId">Tenant id.</param>
public CommericalConfiguration(string tenantId)
{
this.tenantId = tenantId ?? throw new System.ArgumentNullException(nameof(tenantId));
}

/// <inheritdoc/>
public string AzureAd_Instance => "https://login.microsoftonline.com";

/// <inheritdoc/>
public string AzureAd_ValidIssuers => "https://login.microsoftonline.com/TENANT_ID/v2.0,https://sts.windows.net/TENANT_ID/";

/// <inheritdoc/>
public string AuthorityUri => $"https://login.microsoftonline.com/{this.tenantId}";

/// <inheritdoc/>
public string GraphBaseUrl => "https://graph.microsoft.com/v1.0";

/// <inheritdoc/>
public string GraphDefaultScope => "https://graph.microsoft.com/.default";

/// <inheritdoc/>
public string GraphUserReadScope => "https://graph.microsoft.com/User.Read openid profile";

/// <inheritdoc/>
public string TeamsLicenseId => "57ff2da0-773e-42df-b2af-ffb7a2317929";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace Microsoft.Teams.Apps.CompanyCommunicator.Common.Configuration
{
/// <summary>
/// Configuration factory returns relevant configuration for a given environment.
/// </summary>
public class ConfigurationFactory
{
private readonly string tenantId;

/// <summary>
/// Initializes a new instance of the <see cref="ConfigurationFactory"/> class.
/// </summary>
/// <param name="tenantId">Tenant id.</param>
public ConfigurationFactory(string tenantId)
{
this.tenantId = tenantId ?? throw new System.ArgumentNullException(nameof(tenantId));
}

/// <summary>
/// Configuration factory returns relevant configuration for a given environment.
/// </summary>
/// <param name="env">Teams environment.</param>
/// <returns>App configurstion.</returns>
public IAppConfiguration GetAppConfiguration(TeamsEnvironment env)
{
switch (env)
{
case TeamsEnvironment.Commercial:
case TeamsEnvironment.GCC:
return new CommericalConfiguration(this.tenantId);
case TeamsEnvironment.GCCH:
return new GCCHConfiguration(this.tenantId);
default:
return new CommericalConfiguration(this.tenantId);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace Microsoft.Teams.Apps.CompanyCommunicator.Common.Configuration
{
/// <summary>
/// App configuration for GCCH environment.
/// </summary>
internal class GCCHConfiguration : IAppConfiguration
{
private readonly string tenantId;

/// <summary>
/// Initializes a new instance of the <see cref="GCCHConfiguration"/> class.
/// </summary>
/// <param name="tenantId">TenantId.</param>
public GCCHConfiguration(string tenantId)
{
this.tenantId = tenantId ?? throw new System.ArgumentNullException(nameof(tenantId));
}

/// <inheritdoc/>
public string AzureAd_Instance => "https://login.microsoftonline.us/";

/// <inheritdoc/>
public string AzureAd_ValidIssuers => $"https://login.microsoftonline.us/{this.tenantId}/v2.0,https://sts.windows.net/{this.tenantId}/";

/// <inheritdoc/>
public string AuthorityUri => $"https://login.microsoftonline.us/{this.tenantId}";

/// <inheritdoc/>
public string GraphBaseUrl => "https://graph.microsoft.us/v1.0";

/// <inheritdoc/>
public string GraphDefaultScope => "https://graph.microsoft.us/.default";

/// <inheritdoc/>
public string GraphUserReadScope => "https://graph.microsoft.us/User.Read openid profile";

/// <inheritdoc/>
public string TeamsLicenseId => "9953b155-8aef-4c56-92f3-72b0487fce41";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// <copyright file="IAppConfiguration.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// </copyright>

namespace Microsoft.Teams.Apps.CompanyCommunicator.Common.Configuration
{
/// <summary>
/// App configuration interface.
/// </summary>
public interface IAppConfiguration
{
public string AzureAd_Instance { get; }

public string AzureAd_ValidIssuers { get; }

public string AuthorityUri { get; }

public string GraphBaseUrl { get; }

public string GraphDefaultScope { get; }

public string GraphUserReadScope { get; }

public string TeamsLicenseId { get; }
}
}
Loading

0 comments on commit 229c711

Please sign in to comment.