diff --git a/Composer/packages/server/src/models/settings/defaultSettingManager.ts b/Composer/packages/server/src/models/settings/defaultSettingManager.ts index 5eb92ae0d8..5674bae736 100644 --- a/Composer/packages/server/src/models/settings/defaultSettingManager.ts +++ b/Composer/packages/server/src/models/settings/defaultSettingManager.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import set from 'lodash/set'; -import { SensitiveProperties } from '@bfc/shared'; +import { DialogSetting, SensitiveProperties } from '@bfc/shared'; import { UserIdentity } from '@bfc/extension'; import { Path } from '../../utility/path'; @@ -16,7 +16,7 @@ export class DefaultSettingManager extends FileSettingManager { super(basePath, user); } - protected createDefaultSettings = (): any => { + protected createDefaultSettings = (): DialogSetting => { return { feature: { UseShowTypingMiddleware: false, @@ -69,10 +69,11 @@ export class DefaultSettingManager extends FileSettingManager { maxImbalanceRatio: 10, maxUtteranceAllowed: 15000, }, - skill: { + skillConfiguration: { isSkill: false, allowedCallers: ['*'], }, + skill: {}, defaultLanguage: 'en-us', languages: ['en-us'], }; diff --git a/runtime/dotnet/azurewebapp/Authorization/AllowedCallersClaimsValidator.cs b/runtime/dotnet/azurewebapp/Authorization/AllowedCallersClaimsValidator.cs index 8b40fde37d..71b7a191f6 100644 --- a/runtime/dotnet/azurewebapp/Authorization/AllowedCallersClaimsValidator.cs +++ b/runtime/dotnet/azurewebapp/Authorization/AllowedCallersClaimsValidator.cs @@ -15,9 +15,9 @@ public class AllowedCallersClaimsValidator : ClaimsValidator { private readonly List _allowedCallers; - public AllowedCallersClaimsValidator(BotSkillSettings settings) + public AllowedCallersClaimsValidator(BotSkillConfiguration settings) { - // skill.allowedCallers is the setting in the appsettings.json file + // skillConfiguration.allowedCallers is the setting in the appsettings.json file // that consists of the list of parent bot IDs that are allowed to access the skill. // To add a new parent bot, simply edit the AllowedCallers and add // the parent bot's Microsoft app ID to the list. diff --git a/runtime/dotnet/azurewebapp/Startup.cs b/runtime/dotnet/azurewebapp/Startup.cs index 7f02fa4329..c7a52195cc 100644 --- a/runtime/dotnet/azurewebapp/Startup.cs +++ b/runtime/dotnet/azurewebapp/Startup.cs @@ -87,7 +87,7 @@ public IStorage ConfigureStorage(BotSettings settings) public bool IsSkill(BotSettings settings) { - return settings?.Skill?.IsSkill == true; + return settings?.SkillConfiguration?.IsSkill == true; } public BotFrameworkHttpAdapter GetBotAdapter(IStorage storage, BotSettings settings, UserState userState, ConversationState conversationState, IServiceProvider s, TelemetryInitializerMiddleware telemetryInitializerMiddleware) @@ -132,7 +132,11 @@ public void ConfigureServices(IServiceCollection services) // Register AuthConfiguration to enable custom claim validation for skills. if (IsSkill(settings)) { - services.AddSingleton(sp => new AuthenticationConfiguration { ClaimsValidator = new AllowedCallersClaimsValidator(settings.Skill) }); + services.AddSingleton(sp => new AuthenticationConfiguration { ClaimsValidator = new AllowedCallersClaimsValidator(settings.SkillConfiguration) }); + } + else + { + services.AddSingleton(sp => new AuthenticationConfiguration()); } // register components. diff --git a/runtime/dotnet/core/Settings/BotSettings.cs b/runtime/dotnet/core/Settings/BotSettings.cs index 73f8a8c2f2..c706a087e6 100644 --- a/runtime/dotnet/core/Settings/BotSettings.cs +++ b/runtime/dotnet/core/Settings/BotSettings.cs @@ -24,7 +24,7 @@ public class BotSettings public string Bot { get; set; } - public BotSkillSettings Skill { get; set; } + public BotSkillConfiguration SkillConfiguration { get; set; } public class BlobStorageConfiguration { diff --git a/runtime/dotnet/core/Settings/BotSkillSettings.cs b/runtime/dotnet/core/Settings/BotSkillConfiguration.cs similarity index 87% rename from runtime/dotnet/core/Settings/BotSkillSettings.cs rename to runtime/dotnet/core/Settings/BotSkillConfiguration.cs index 35214931b6..7f78a46d22 100644 --- a/runtime/dotnet/core/Settings/BotSkillSettings.cs +++ b/runtime/dotnet/core/Settings/BotSkillConfiguration.cs @@ -3,7 +3,7 @@ namespace Microsoft.BotFramework.Composer.Core.Settings { - public class BotSkillSettings + public class BotSkillConfiguration { // Is skill public bool IsSkill { get; set; } diff --git a/runtime/dotnet/tests/AllowedCallersClaimsValidationTests.cs b/runtime/dotnet/tests/AllowedCallersClaimsValidationTests.cs index e96e7cb7ed..ac123eb05f 100644 --- a/runtime/dotnet/tests/AllowedCallersClaimsValidationTests.cs +++ b/runtime/dotnet/tests/AllowedCallersClaimsValidationTests.cs @@ -19,14 +19,14 @@ public class AllowedCallersClaimsValidationTests [ExpectedException(typeof(ArgumentException))] public void WhenAllowedCallersIsNullThrowException() { - var unused = new AllowedCallersClaimsValidator(new BotSkillSettings()); + var unused = new AllowedCallersClaimsValidator(new BotSkillConfiguration()); } [TestMethod] [ExpectedException(typeof(ArgumentException))] public void WhenAllowedCallersIsEmptyThrowException() { - var unused = new AllowedCallersClaimsValidator(new BotSkillSettings() + var unused = new AllowedCallersClaimsValidator(new BotSkillConfiguration() { AllowedCallers = new string[0] }); @@ -35,7 +35,7 @@ public void WhenAllowedCallersIsEmptyThrowException() [TestMethod] public async Task AllowAnyCaller() { - var validator = new AllowedCallersClaimsValidator(new BotSkillSettings() + var validator = new AllowedCallersClaimsValidator(new BotSkillConfiguration() { AllowedCallers = new string[]{"*"} }); @@ -49,7 +49,7 @@ public async Task AllowAnyCaller() public async Task AllowedCaller() { const string callerAppId = "BE3F9920-D42D-4D3A-9BDF-DBA62DAE3A00"; - var validator = new AllowedCallersClaimsValidator(new BotSkillSettings() + var validator = new AllowedCallersClaimsValidator(new BotSkillConfiguration() { AllowedCallers = new string[]{callerAppId} }); @@ -63,7 +63,7 @@ public async Task AllowedCaller() public async Task AllowedCallers() { const string callerAppId = "BE3F9920-D42D-4D3A-9BDF-DBA62DAE3A00"; - var validator = new AllowedCallersClaimsValidator(new BotSkillSettings() + var validator = new AllowedCallersClaimsValidator(new BotSkillConfiguration() { AllowedCallers = new string[]{"anotherId", callerAppId} }); @@ -78,7 +78,7 @@ public async Task AllowedCallers() public async Task NonAllowedCallerShouldThrowException() { var callerAppId = "BE3F9920-D42D-4D3A-9BDF-DBA62DAE3A00"; - var validator = new AllowedCallersClaimsValidator(new BotSkillSettings() + var validator = new AllowedCallersClaimsValidator(new BotSkillConfiguration() { AllowedCallers = new string[]{callerAppId} });