Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 25c80c0

Browse files
authored
Merge pull request #3830 from southworks/internal/feature/southworks/virtual-assistant/allowedCallersClaimsValidator-issue
[TypeScript][Virtual Assistant] Add claim's validation if the VA is not connected to Skills
2 parents 60f6ed7 + 005d25d commit 25c80c0

File tree

2 files changed

+18
-10
lines changed
  • templates/typescript
    • generator-bot-virtualassistant/generators/app/templates/sample-assistant/src
    • samples/sample-assistant/src

2 files changed

+18
-10
lines changed

templates/typescript/generator-bot-virtualassistant/generators/app/templates/sample-assistant/src/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,16 @@ const credentialProvider: SimpleCredentialProvider = new SimpleCredentialProvide
7777
// Register the skills configuration class.
7878
const skillsConfig: SkillsConfiguration = new SkillsConfiguration(appsettings.botFrameworkSkills as IEnhancedBotFrameworkSkill[], appsettings.skillHostEndpoint);
7979

80+
let authenticationConfiguration = new AuthenticationConfiguration();
81+
8082
// Register AuthConfiguration to enable custom claim validation.
81-
const allowedCallers: string[] = [...skillsConfig.skills.values()].map(skill => skill.appId);
82-
const authenticationConfiguration = new AuthenticationConfiguration(
83-
undefined,
84-
allowedCallersClaimsValidator(allowedCallers)
85-
);
83+
if (skillsConfig.skills.size > 0) {
84+
const allowedCallers: string[] = [...skillsConfig.skills.values()].map(skill => skill.appId);
85+
authenticationConfiguration = new AuthenticationConfiguration(
86+
undefined,
87+
allowedCallersClaimsValidator(allowedCallers)
88+
);
89+
}
8690

8791
// Configure telemetry
8892
const telemetryClient: BotTelemetryClient = getTelemetryClient(settings);

templates/typescript/samples/sample-assistant/src/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,16 @@ const credentialProvider: SimpleCredentialProvider = new SimpleCredentialProvide
7777
// Register the skills configuration class.
7878
const skillsConfig: SkillsConfiguration = new SkillsConfiguration(appsettings.botFrameworkSkills as IEnhancedBotFrameworkSkill[], appsettings.skillHostEndpoint);
7979

80+
let authenticationConfiguration = new AuthenticationConfiguration();
81+
8082
// Register AuthConfiguration to enable custom claim validation.
81-
const allowedCallers: string[] = [...skillsConfig.skills.values()].map(skill => skill.appId);
82-
const authenticationConfiguration = new AuthenticationConfiguration(
83-
undefined,
84-
allowedCallersClaimsValidator(allowedCallers)
85-
);
83+
if (skillsConfig.skills.size > 0) {
84+
const allowedCallers: string[] = [...skillsConfig.skills.values()].map(skill => skill.appId);
85+
authenticationConfiguration = new AuthenticationConfiguration(
86+
undefined,
87+
allowedCallersClaimsValidator(allowedCallers)
88+
);
89+
}
8690

8791
// Configure telemetry
8892
const telemetryClient: BotTelemetryClient = getTelemetryClient(settings);

0 commit comments

Comments
 (0)