Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -261,7 +261,7 @@ private async Task<ClaimsPrincipal> ValidateTokenAsync(string jwtToken, string c

// Validate Channel / Token Endorsements. For this, the channelID present on the Activity
// needs to be matched by an endorsement.
var keyId = (string)parsedJwtToken?.Header?[AuthenticationConstants.KeyIdHeader];
var keyId = parsedToken.SigningKey.KeyId;
var endorsements = await _endorsementsData.GetConfigurationAsync().ConfigureAwait(false);

// Note: On the Emulator Code Path, the endorsements collection is empty so the validation code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,18 @@ public async Task ExpiredTokenShouldThrowUnauthorizedAccessException()
var headerDictionaryMock = new Mock<IHeaderDictionary>();

// Expired token with removed AppID
// This token will be validated against real endpoint https://login.microsoftonline.com/common/discovery/v2.0/keys
// So when the signing key is removed in endpoint, it will not be Expired exception, we need to generate a new token
// - create a new app registration: https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/CreateApplicationBlade/quickStartType~/null/isMSAApp~/false
// - create an access token via powershell script (need to wait for one day so it is expired)
// $Form = @{
// client_id = "YOUR_APP_ID"
// scope = "https://api.botframework.com/.default"
// client_secret = "YOUR_APP_SECRET"
// grant_type = "client_credentials"
// }
// (Invoke-WebRequest -Uri 'https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token' -Method Post -Form $Form).Content
// - delete the app
var token = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSIsImtpZCI6IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSJ9.eyJhdWQiOiJodHRwczovL2FwaS5ib3RmcmFtZXdvcmsuY29tIiwiaXNzIjoia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