Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support Single Tenant authentication through BotFramework-Emulator #4643

Merged
merged 6 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ export namespace AuthenticationConstants {
*/
export const ServiceUrlClaim = 'serviceurl';

/**
* Tenant ID claim name. As used in Microsoft AAD tokens.
*/
export const TenantIdClaim = 'tid';

/**
* AppId used for creating skill claims when there is no appId and password configured.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,29 @@ export namespace EmulatorValidation {
}

// Is there an Issuer?
const issuer: string = token.payload.iss;
const issuer: string = token.payload[AuthenticationConstants.IssuerClaim];
if (!issuer) {
// No Issuer, means it's not from the Emulator.
return false;
}

//Validation to manage the issuer object as a string.
if (Array.isArray(ToBotFromBotOrEmulatorTokenValidationParameters.issuer)) {
const tenantId = token?.payload[AuthenticationConstants.TenantIdClaim] ?? '';

//Validate if there is an existing issuer with the same tid value.
if (
tenantId != '' &&
ToBotFromBotOrEmulatorTokenValidationParameters.issuer.find((issuer) => issuer.includes(tenantId)) ==
null
) {
//If the issuer doesn't exist, this is added using the Emulator token issuer structure.
//This allows use of the SingleTenant authentication through Emulator.
const newIssuer = AuthenticationConstants.ValidTokenIssuerUrlTemplateV1 + `${tenantId}/`;
ToBotFromBotOrEmulatorTokenValidationParameters.issuer.push(newIssuer);
}
}

// Is the token issues by a source we consider to be the emulator?
if (
ToBotFromEmulatorTokenValidationParameters.issuer &&
Expand Down
Loading