Skip to content

Commit

Permalink
Merge pull request microsoft#3830 from southworks/internal/feature/so…
Browse files Browse the repository at this point in the history
…uthworks/virtual-assistant/allowedCallersClaimsValidator-issue

[TypeScript][Virtual Assistant] Add claim's validation if the VA is not connected to Skills
  • Loading branch information
lauren-mills authored Jun 21, 2021
2 parents 60f6ed7 + 005d25d commit 25c80c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 9 additions & 5 deletions templates/typescript/samples/sample-assistant/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 25c80c0

Please sign in to comment.