Skip to content

Commit b632b84

Browse files
authored
Merge branch 'master' into kyled/ActivityPrompt
2 parents c34e994 + 35bbf9f commit b632b84

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

libraries/botbuilder-core/botbuilder/core/bot_framework_adapter.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,18 @@ async def continue_conversation(
279279
context.turn_state[BotAdapter.BOT_CALLBACK_HANDLER_KEY] = callback
280280
context.turn_state[BotAdapter.BOT_OAUTH_SCOPE_KEY] = audience
281281

282-
# Add the channel service URL to the trusted services list so we can send messages back.
283-
# the service URL for skills is trusted because it is applied by the SkillHandler based
284-
# on the original request received by the root bot
285-
AppCredentials.trust_service_url(reference.service_url)
282+
# If we receive a valid app id in the incoming token claims, add the channel service URL to the
283+
# trusted services list so we can send messages back.
284+
# The service URL for skills is trusted because it is applied by the SkillHandler based on the original
285+
# request received by the root bot
286+
app_id_from_claims = JwtTokenValidation.get_app_id_from_claims(
287+
claims_identity.claims
288+
)
289+
if app_id_from_claims:
290+
if SkillValidation.is_skill_claim(
291+
claims_identity.claims
292+
) or await self._credential_provider.is_valid_appid(app_id_from_claims):
293+
AppCredentials.trust_service_url(reference.service_url)
286294

287295
client = await self.create_connector_client(
288296
reference.service_url, claims_identity, audience

libraries/botbuilder-core/tests/test_bot_framework_adapter.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,14 @@ async def callback(context: TurnContext):
571571
scope = context.turn_state[BotFrameworkAdapter.BOT_OAUTH_SCOPE_KEY]
572572
assert AuthenticationConstants.TO_CHANNEL_FROM_BOT_OAUTH_SCOPE == scope
573573

574+
# Ensure the serviceUrl was added to the trusted hosts
575+
assert AppCredentials.is_trusted_service(channel_service_url)
576+
574577
refs = ConversationReference(service_url=channel_service_url)
575578

579+
# Ensure the serviceUrl is NOT in the trusted hosts
580+
assert not AppCredentials.is_trusted_service(channel_service_url)
581+
576582
await adapter.continue_conversation(
577583
refs, callback, claims_identity=skills_identity
578584
)
@@ -629,8 +635,14 @@ async def callback(context: TurnContext):
629635
scope = context.turn_state[BotFrameworkAdapter.BOT_OAUTH_SCOPE_KEY]
630636
assert skill_2_app_id == scope
631637

638+
# Ensure the serviceUrl was added to the trusted hosts
639+
assert AppCredentials.is_trusted_service(skill_2_service_url)
640+
632641
refs = ConversationReference(service_url=skill_2_service_url)
633642

643+
# Ensure the serviceUrl is NOT in the trusted hosts
644+
assert not AppCredentials.is_trusted_service(skill_2_service_url)
645+
634646
await adapter.continue_conversation(
635647
refs, callback, claims_identity=skills_identity, audience=skill_2_app_id
636648
)

0 commit comments

Comments
 (0)