From 232cbbdec44715824cca57a172f79bc9413e4bd7 Mon Sep 17 00:00:00 2001 From: Federico Bernal <64086728+FedericoBernal@users.noreply.github.com> Date: Thu, 17 Jun 2021 15:22:54 -0300 Subject: [PATCH 1/3] Fix allowedCallersClaimsValidator issue --- .../samples/sample-assistant/src/index.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/templates/typescript/samples/sample-assistant/src/index.ts b/templates/typescript/samples/sample-assistant/src/index.ts index 0a172be632..16e0e58d12 100644 --- a/templates/typescript/samples/sample-assistant/src/index.ts +++ b/templates/typescript/samples/sample-assistant/src/index.ts @@ -77,12 +77,16 @@ const credentialProvider: SimpleCredentialProvider = new SimpleCredentialProvide // Register the skills configuration class. const skillsConfig: SkillsConfiguration = new SkillsConfiguration(appsettings.botFrameworkSkills as IEnhancedBotFrameworkSkill[], appsettings.skillHostEndpoint); +let authenticationConfiguration = new AuthenticationConfiguration(); + // Register AuthConfiguration to enable custom claim validation. -const allowedCallers: string[] = [...skillsConfig.skills.values()].map(skill => skill.appId); -const authenticationConfiguration = new AuthenticationConfiguration( - undefined, - allowedCallersClaimsValidator(allowedCallers) -); +if(skillsConfig.skills.size > 0){ + const allowedCallers: string[] = [...skillsConfig.skills.values()].map(skill => skill.appId); + const authenticationConfiguration = new AuthenticationConfiguration( + undefined, + allowedCallersClaimsValidator(allowedCallers) + ); +} // Configure telemetry const telemetryClient: BotTelemetryClient = getTelemetryClient(settings); From f1061fabb625785b8ad405b079e73ef4832a9ca2 Mon Sep 17 00:00:00 2001 From: Federico Bernal <64086728+FedericoBernal@users.noreply.github.com> Date: Thu, 17 Jun 2021 15:37:42 -0300 Subject: [PATCH 2/3] Apply feedback --- templates/typescript/samples/sample-assistant/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/typescript/samples/sample-assistant/src/index.ts b/templates/typescript/samples/sample-assistant/src/index.ts index 16e0e58d12..592c318400 100644 --- a/templates/typescript/samples/sample-assistant/src/index.ts +++ b/templates/typescript/samples/sample-assistant/src/index.ts @@ -80,9 +80,9 @@ const skillsConfig: SkillsConfiguration = new SkillsConfiguration(appsettings.bo let authenticationConfiguration = new AuthenticationConfiguration(); // Register AuthConfiguration to enable custom claim validation. -if(skillsConfig.skills.size > 0){ +if (skillsConfig.skills.size > 0) { const allowedCallers: string[] = [...skillsConfig.skills.values()].map(skill => skill.appId); - const authenticationConfiguration = new AuthenticationConfiguration( + authenticationConfiguration = new AuthenticationConfiguration( undefined, allowedCallersClaimsValidator(allowedCallers) ); From 005d25d473ebf01c8158c1a67d6d1c6b227f2fe0 Mon Sep 17 00:00:00 2001 From: Federico Bernal <64086728+FedericoBernal@users.noreply.github.com> Date: Thu, 17 Jun 2021 16:01:39 -0300 Subject: [PATCH 3/3] Apply fix of allowedCallersClaimsValidator for the generator template --- .../app/templates/sample-assistant/src/index.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/templates/typescript/generator-bot-virtualassistant/generators/app/templates/sample-assistant/src/index.ts b/templates/typescript/generator-bot-virtualassistant/generators/app/templates/sample-assistant/src/index.ts index 0a172be632..592c318400 100644 --- a/templates/typescript/generator-bot-virtualassistant/generators/app/templates/sample-assistant/src/index.ts +++ b/templates/typescript/generator-bot-virtualassistant/generators/app/templates/sample-assistant/src/index.ts @@ -77,12 +77,16 @@ const credentialProvider: SimpleCredentialProvider = new SimpleCredentialProvide // Register the skills configuration class. const skillsConfig: SkillsConfiguration = new SkillsConfiguration(appsettings.botFrameworkSkills as IEnhancedBotFrameworkSkill[], appsettings.skillHostEndpoint); +let authenticationConfiguration = new AuthenticationConfiguration(); + // Register AuthConfiguration to enable custom claim validation. -const allowedCallers: string[] = [...skillsConfig.skills.values()].map(skill => skill.appId); -const authenticationConfiguration = new AuthenticationConfiguration( - undefined, - allowedCallersClaimsValidator(allowedCallers) -); +if (skillsConfig.skills.size > 0) { + const allowedCallers: string[] = [...skillsConfig.skills.values()].map(skill => skill.appId); + authenticationConfiguration = new AuthenticationConfiguration( + undefined, + allowedCallersClaimsValidator(allowedCallers) + ); +} // Configure telemetry const telemetryClient: BotTelemetryClient = getTelemetryClient(settings);